# reference
# https://www.youtube.com/watch?v=OSA5fZZwEW4
from IPython.display import display, clear_output
import ipywidgets as widgets
from ipywidgets import interact, interactive, fixed, interact_manual
import pandas as pd
import numpy as np
from os import listdir
import shutil
import os
import torch
import torch.nn as nn
from torchvision import datasets, transforms, models
from torch.utils.data import DataLoader
from torch import optim
from PIL import Image
import pandas as pd
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from os import listdir
import shutil
import os
import torch
import torch.nn as nn
from torchvision import datasets, transforms, models
from torch.utils.data import DataLoader
from torch import optim
from PIL import Image
import pandas as pd
import matplotlib.pyplot as plt
experiment_number = 7
isize = 256
iusize = 1024
num_epochs = 1000
import os
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = 'max_split_size_mb:128'
img = Image.open("example_input_" + str(experiment_number) + ".png").convert("RGB")
transform = transforms.Compose([
transforms.Resize(isize),
transforms.CenterCrop(isize),
transforms.ToTensor()
])
img = transform(img)
img = img.cuda()
avg_pool = nn.AvgPool2d(21, stride=1, padding=10)
avg_img = avg_pool(img)
img_var = avg_pool((img - avg_img).square()).sqrt()
class EllipseModel(nn.Module):
def __init__(self, n, use_cuda=True):
super(EllipseModel, self).__init__()
self.num = n
self.fr = 4 # Fourier terms
self.use_cuda = use_cuda
self.posx = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
self.posy = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
self.radius = torch.nn.Parameter(torch.randn((self.num), requires_grad=True))
self.width = torch.nn.Parameter(torch.randn((self.num), requires_grad=True))
self.length = torch.nn.Parameter(torch.randn((self.num), requires_grad=True))
# self.fweights_sin = torch.nn.Parameter(
# torch.rand((self.fr, self.num), requires_grad=True))
# self.fweights_cos = torch.nn.Parameter(
# torch.rand((self.fr, self.num), requires_grad=True))
self.scale_x = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
self.scale_y = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
self.color = torch.nn.Parameter(
torch.zeros((self.num, 3), requires_grad=True))
self.alpha = torch.nn.Parameter(
torch.zeros((self.num), requires_grad=True))
self.rotate = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
# self.order = torch.nn.Parameter(
# torch.rand((self.num), requires_grad=True))
def forward(self, isize, t):
posx = self.posx
posy = self.posy
radius = self.radius * 1.0
width = self.width.sigmoid() * float(1 << 12)
length = self.length.sigmoid() * 128.0
# colors = (self.colors).sigmoid()* 1.0
color = (self.color)
alpha = (self.alpha).sigmoid() * 16.0
# background = (self.background).sigmoid() + 0.5
rotate = 3.141592 * self.rotate.sigmoid() * 8.0
scale_x = (self.scale_x).sigmoid() * 16.0
scale_y = (self.scale_y).sigmoid() * 16.0
# order = self.order.sigmoid() * 8.0
# fweights_sin = self.fweights_sin.sigmoid() * 2.0
# fweights_cos = self.fweights_cos.sigmoid() * 2.0
fr = self.fr # Fourier terms
X = torch.unsqueeze(torch.arange(
0.5, isize + 0.5, 1) / isize, 0)
Y = torch.unsqueeze(torch.arange(
0.5, isize + 0.5, 1) / isize, 0)
I = torch.unsqueeze(torch.ones(isize), 0)
if self.use_cuda:
X = X.cuda()
Y = Y.cuda()
I = I.cuda()
X = X * I
Y = torch.transpose(Y * I, 0, 1)
X = X.unsqueeze_(0)
Y = Y.unsqueeze_(0)
X = X.expand(self.num, 1, isize, isize) - \
posx.reshape(self.num, 1, 1, 1)
Y = Y.expand(self.num, 1, isize, isize) - \
posy.reshape(self.num, 1, 1, 1)
X, Y = X * (rotate.reshape(self.num, 1, 1, 1).cos()) - Y * (rotate.reshape(self.num, 1, 1, 1,).sin()), \
X * (rotate.reshape(self.num, 1, 1, 1).sin()) + \
Y * (rotate.reshape(self.num, 1, 1, 1).cos())
X = scale_x.reshape(self.num, 1, 1, 1) * X
Y = scale_y.reshape(self.num, 1, 1, 1) * Y
R = torch.sqrt(X.square() + Y.square())
theta = -1.0 * (torch.acos(X / (R + 0.0001)) *
(1.0 * (Y > 0.0) - 1.0 * (Y < 0.0)))
# fourier = torch.arange(1, fr + 1).expand(self.num,
# fr).permute(1, 0).reshape(fr, self.num, 1, 1, 1)
# if self.use_cuda:
# fourier = fourier.cuda()
# fourier = (fourier * (theta.expand(fr, self.num, 1, isize, isize)))
# fourier = (fweights_sin.reshape(fr, self.num, 1, 1, 1) * fourier.sin() +
# fweights_cos.reshape(fr, self.num, 1, 1, 1) * fourier.cos()).sum(0)
fourier = 0.0
filter_values = (radius.reshape(self.num, 1, 1, 1) * (1.0 + 0.1 * fourier) - R)
# sharpness = float(1 << 9)
filters_soft = torch.exp(-width.reshape(self.num, 1, 1, 1) * filter_values * filter_values)
filters2 = filters_soft * (filters_soft > 0.0)
angle_alpha = torch.pow(1.0 - torch.cos(theta / 2.0), length.reshape(self.num, 1, 1, 1))
return (color, alpha, angle_alpha, filters2, radius, theta)
num = 1024
model = EllipseModel(num, use_cuda=True)
model = model.cuda()
optimizer = optim.AdamW(model.parameters(), lr=0.005)
out = None
try:
shutil.rmtree('.scratch')
except:
pass
os.mkdir('.scratch')
def brightness(val):
return torch.sqrt(0.241*(val[0]**2) + 0.691*(val[1]**2) + 0.068*(val[2]**2))
upsampler = nn.Upsample(scale_factor=2, mode='bicubic')
for epoch in range(0, num_epochs):
with torch.amp.autocast(device_type="cuda", dtype=torch.float16):
torch.cuda.empty_cache()
color, alpha, angle_alpha, filters2, radius, theta = model(isize, -16.0)
# rgb = torch.sum(filters2.expand(num, 3, isize, isize), (0),
# keepdim=True)/(torch.sum(filters2.expand(num, 3, isize, isize), (0), keepdim=True)+0.00001)
# bg = torch.tensor([1.0]).expand(3, isize, isize).cuda() * torch.exp(-(torch.sum(torch.pow(1.0 - torch.cos(theta / 2.0), 8.0).reshape(num, 1, isize, isize) * alpha.reshape(num, 1, 1, 1).expand(num, 1, isize, isize) * filters2.expand(num, 1, isize, isize), (0))))
radius_alpha = filters2
# bg = torch.sum(angle_alpha.reshape(num, 1, isize, isize) * radius_alpha.reshape(num, 1, isize, isize) * color.reshape(num, 3, 1, 1).expand(num, 3, isize, isize) * torch.exp(-alpha).reshape(num, 1, 1, 1).expand(num, 1, isize, isize), (0)) / (torch.sum(angle_alpha.reshape(num, 1, isize, isize) * radius_alpha.reshape(num, 1, isize, isize) * torch.exp(-alpha).reshape(num, 1, 1, 1).expand(num, 1, isize, isize), (0)) + 0.00001)
bg = torch.sum(angle_alpha.reshape(num, 1, isize, isize) * radius_alpha.reshape(num, 1, isize, isize) * color.reshape(num, 3, 1, 1).expand(num, 3, isize, isize) * torch.exp(-alpha).reshape(num, 1, 1, 1).expand(num, 1, isize, isize), (0)) / (torch.sum(angle_alpha.reshape(num, 1, isize, isize) * radius_alpha.reshape(num, 1, isize, isize) * torch.exp(-alpha).reshape(num, 1, 1, 1).expand(num, 1, isize, isize), (0)) + 0.00001)
out = bg.cuda()
# pic_loss = (((( (img-out) )))).abs().mean()
# pic_loss = (((( (avg_img-out).abs() + (img-out).abs() ).square()))).mean().sqrt()
pic_loss = (((( (img-out) ).square()))).mean().sqrt()
# pic_loss = ((((brightness( (img-out)) ).square()))).mean().sqrt()
# pic_loss = (brightness(img-out)/brightness(avg_img) ).square().mean().sqrt()
# pic_loss = ((((( img_var*(img-out))/avg_img ).square()))).mean().sqrt()
loss = pic_loss
optimizer.zero_grad()
loss.backward()
optimizer.step()
# im = Image.fromarray((255.0 * out.clamp(0.0, 1.0).detach().permute(1,2,0).cpu().numpy()).astype(np.uint8), 'RGB').convert('RGB')
im = out.clamp(0.0, 1.0).detach().permute(1,2,0).cpu().numpy()
# im = im.resize((iusize, iusize), Image.LANCZOS)
plt.imsave(".scratch/out_" + str(epoch) + ".png", im)
print(f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}')
torch.save(model.state_dict(), 'model.ckpt')
Epoch [1/1000], Loss: 0.4353 Epoch [2/1000], Loss: 0.4351 Epoch [3/1000], Loss: 0.4348 Epoch [4/1000], Loss: 0.4344 Epoch [5/1000], Loss: 0.4340 Epoch [6/1000], Loss: 0.4336 Epoch [7/1000], Loss: 0.4332 Epoch [8/1000], Loss: 0.4328 Epoch [9/1000], Loss: 0.4323 Epoch [10/1000], Loss: 0.4318 Epoch [11/1000], Loss: 0.4313 Epoch [12/1000], Loss: 0.4308 Epoch [13/1000], Loss: 0.4303 Epoch [14/1000], Loss: 0.4297 Epoch [15/1000], Loss: 0.4291 Epoch [16/1000], Loss: 0.4285 Epoch [17/1000], Loss: 0.4279 Epoch [18/1000], Loss: 0.4273 Epoch [19/1000], Loss: 0.4267 Epoch [20/1000], Loss: 0.4260 Epoch [21/1000], Loss: 0.4253 Epoch [22/1000], Loss: 0.4246 Epoch [23/1000], Loss: 0.4238 Epoch [24/1000], Loss: 0.4230 Epoch [25/1000], Loss: 0.4222 Epoch [26/1000], Loss: 0.4214 Epoch [27/1000], Loss: 0.4205 Epoch [28/1000], Loss: 0.4196 Epoch [29/1000], Loss: 0.4187 Epoch [30/1000], Loss: 0.4177 Epoch [31/1000], Loss: 0.4168 Epoch [32/1000], Loss: 0.4157 Epoch [33/1000], Loss: 0.4146 Epoch [34/1000], Loss: 0.4135 Epoch [35/1000], Loss: 0.4124 Epoch [36/1000], Loss: 0.4113 Epoch [37/1000], Loss: 0.4100 Epoch [38/1000], Loss: 0.4088 Epoch [39/1000], Loss: 0.4075 Epoch [40/1000], Loss: 0.4061 Epoch [41/1000], Loss: 0.4048 Epoch [42/1000], Loss: 0.4034 Epoch [43/1000], Loss: 0.4019 Epoch [44/1000], Loss: 0.4004 Epoch [45/1000], Loss: 0.3989 Epoch [46/1000], Loss: 0.3972 Epoch [47/1000], Loss: 0.3954 Epoch [48/1000], Loss: 0.3937 Epoch [49/1000], Loss: 0.3918 Epoch [50/1000], Loss: 0.3900 Epoch [51/1000], Loss: 0.3880 Epoch [52/1000], Loss: 0.3861 Epoch [53/1000], Loss: 0.3841 Epoch [54/1000], Loss: 0.3820 Epoch [55/1000], Loss: 0.3798 Epoch [56/1000], Loss: 0.3776 Epoch [57/1000], Loss: 0.3753 Epoch [58/1000], Loss: 0.3729 Epoch [59/1000], Loss: 0.3705 Epoch [60/1000], Loss: 0.3679 Epoch [61/1000], Loss: 0.3654 Epoch [62/1000], Loss: 0.3626 Epoch [63/1000], Loss: 0.3599 Epoch [64/1000], Loss: 0.3570 Epoch [65/1000], Loss: 0.3540 Epoch [66/1000], Loss: 0.3511 Epoch [67/1000], Loss: 0.3481 Epoch [68/1000], Loss: 0.3451 Epoch [69/1000], Loss: 0.3419 Epoch [70/1000], Loss: 0.3386 Epoch [71/1000], Loss: 0.3349 Epoch [72/1000], Loss: 0.3316 Epoch [73/1000], Loss: 0.3279 Epoch [74/1000], Loss: 0.3244 Epoch [75/1000], Loss: 0.3209 Epoch [76/1000], Loss: 0.3171 Epoch [77/1000], Loss: 0.3131 Epoch [78/1000], Loss: 0.3091 Epoch [79/1000], Loss: 0.3048 Epoch [80/1000], Loss: 0.3005 Epoch [81/1000], Loss: 0.2963 Epoch [82/1000], Loss: 0.2921 Epoch [83/1000], Loss: 0.2877 Epoch [84/1000], Loss: 0.2831 Epoch [85/1000], Loss: 0.2786 Epoch [86/1000], Loss: 0.2737 Epoch [87/1000], Loss: 0.2694 Epoch [88/1000], Loss: 0.2646 Epoch [89/1000], Loss: 0.2598 Epoch [90/1000], Loss: 0.2554 Epoch [91/1000], Loss: 0.2509 Epoch [92/1000], Loss: 0.2461 Epoch [93/1000], Loss: 0.2413 Epoch [94/1000], Loss: 0.2368 Epoch [95/1000], Loss: 0.2319 Epoch [96/1000], Loss: 0.2272 Epoch [97/1000], Loss: 0.2225 Epoch [98/1000], Loss: 0.2174 Epoch [99/1000], Loss: 0.2134 Epoch [100/1000], Loss: 0.2084 Epoch [101/1000], Loss: 0.2040 Epoch [102/1000], Loss: 0.1997 Epoch [103/1000], Loss: 0.1953 Epoch [104/1000], Loss: 0.1910 Epoch [105/1000], Loss: 0.1866 Epoch [106/1000], Loss: 0.1823 Epoch [107/1000], Loss: 0.1782 Epoch [108/1000], Loss: 0.1739 Epoch [109/1000], Loss: 0.1703 Epoch [110/1000], Loss: 0.1664 Epoch [111/1000], Loss: 0.1632 Epoch [112/1000], Loss: 0.1594 Epoch [113/1000], Loss: 0.1561 Epoch [114/1000], Loss: 0.1528 Epoch [115/1000], Loss: 0.1497 Epoch [116/1000], Loss: 0.1464 Epoch [117/1000], Loss: 0.1437 Epoch [118/1000], Loss: 0.1407 Epoch [119/1000], Loss: 0.1379 Epoch [120/1000], Loss: 0.1352 Epoch [121/1000], Loss: 0.1324 Epoch [122/1000], Loss: 0.1299 Epoch [123/1000], Loss: 0.1275 Epoch [124/1000], Loss: 0.1252 Epoch [125/1000], Loss: 0.1227 Epoch [126/1000], Loss: 0.1203 Epoch [127/1000], Loss: 0.1180 Epoch [128/1000], Loss: 0.1162 Epoch [129/1000], Loss: 0.1141 Epoch [130/1000], Loss: 0.1122 Epoch [131/1000], Loss: 0.1105 Epoch [132/1000], Loss: 0.1082 Epoch [133/1000], Loss: 0.1069 Epoch [134/1000], Loss: 0.1050 Epoch [135/1000], Loss: 0.1036 Epoch [136/1000], Loss: 0.1022 Epoch [137/1000], Loss: 0.1008 Epoch [138/1000], Loss: 0.0994 Epoch [139/1000], Loss: 0.0980 Epoch [140/1000], Loss: 0.0968 Epoch [141/1000], Loss: 0.0957 Epoch [142/1000], Loss: 0.0947 Epoch [143/1000], Loss: 0.0934 Epoch [144/1000], Loss: 0.0924 Epoch [145/1000], Loss: 0.0915 Epoch [146/1000], Loss: 0.0905 Epoch [147/1000], Loss: 0.0896 Epoch [148/1000], Loss: 0.0886 Epoch [149/1000], Loss: 0.0878 Epoch [150/1000], Loss: 0.0870 Epoch [151/1000], Loss: 0.0863 Epoch [152/1000], Loss: 0.0856 Epoch [153/1000], Loss: 0.0849 Epoch [154/1000], Loss: 0.0842 Epoch [155/1000], Loss: 0.0835 Epoch [156/1000], Loss: 0.0829 Epoch [157/1000], Loss: 0.0824 Epoch [158/1000], Loss: 0.0818 Epoch [159/1000], Loss: 0.0812 Epoch [160/1000], Loss: 0.0807 Epoch [161/1000], Loss: 0.0800 Epoch [162/1000], Loss: 0.0796 Epoch [163/1000], Loss: 0.0791 Epoch [164/1000], Loss: 0.0786 Epoch [165/1000], Loss: 0.0780 Epoch [166/1000], Loss: 0.0776 Epoch [167/1000], Loss: 0.0771 Epoch [168/1000], Loss: 0.0765 Epoch [169/1000], Loss: 0.0761 Epoch [170/1000], Loss: 0.0757 Epoch [171/1000], Loss: 0.0753 Epoch [172/1000], Loss: 0.0748 Epoch [173/1000], Loss: 0.0744 Epoch [174/1000], Loss: 0.0741 Epoch [175/1000], Loss: 0.0737 Epoch [176/1000], Loss: 0.0733 Epoch [177/1000], Loss: 0.0731 Epoch [178/1000], Loss: 0.0727 Epoch [179/1000], Loss: 0.0725 Epoch [180/1000], Loss: 0.0721 Epoch [181/1000], Loss: 0.0718 Epoch [182/1000], Loss: 0.0716 Epoch [183/1000], Loss: 0.0713 Epoch [184/1000], Loss: 0.0712 Epoch [185/1000], Loss: 0.0710 Epoch [186/1000], Loss: 0.0708 Epoch [187/1000], Loss: 0.0704 Epoch [188/1000], Loss: 0.0703 Epoch [189/1000], Loss: 0.0700 Epoch [190/1000], Loss: 0.0698 Epoch [191/1000], Loss: 0.0696 Epoch [192/1000], Loss: 0.0694 Epoch [193/1000], Loss: 0.0692 Epoch [194/1000], Loss: 0.0690 Epoch [195/1000], Loss: 0.0688 Epoch [196/1000], Loss: 0.0686 Epoch [197/1000], Loss: 0.0684 Epoch [198/1000], Loss: 0.0682 Epoch [199/1000], Loss: 0.0680 Epoch [200/1000], Loss: 0.0678 Epoch [201/1000], Loss: 0.0676 Epoch [202/1000], Loss: 0.0674 Epoch [203/1000], Loss: 0.0672 Epoch [204/1000], Loss: 0.0671 Epoch [205/1000], Loss: 0.0668 Epoch [206/1000], Loss: 0.0667 Epoch [207/1000], Loss: 0.0665 Epoch [208/1000], Loss: 0.0663 Epoch [209/1000], Loss: 0.0661 Epoch [210/1000], Loss: 0.0660 Epoch [211/1000], Loss: 0.0658 Epoch [212/1000], Loss: 0.0656 Epoch [213/1000], Loss: 0.0654 Epoch [214/1000], Loss: 0.0652 Epoch [215/1000], Loss: 0.0651 Epoch [216/1000], Loss: 0.0649 Epoch [217/1000], Loss: 0.0647 Epoch [218/1000], Loss: 0.0646 Epoch [219/1000], Loss: 0.0644 Epoch [220/1000], Loss: 0.0642 Epoch [221/1000], Loss: 0.0641 Epoch [222/1000], Loss: 0.0640 Epoch [223/1000], Loss: 0.0639 Epoch [224/1000], Loss: 0.0637 Epoch [225/1000], Loss: 0.0634 Epoch [226/1000], Loss: 0.0634 Epoch [227/1000], Loss: 0.0632 Epoch [228/1000], Loss: 0.0630 Epoch [229/1000], Loss: 0.0629 Epoch [230/1000], Loss: 0.0626 Epoch [231/1000], Loss: 0.0625 Epoch [232/1000], Loss: 0.0623 Epoch [233/1000], Loss: 0.0622 Epoch [234/1000], Loss: 0.0620 Epoch [235/1000], Loss: 0.0618 Epoch [236/1000], Loss: 0.0617 Epoch [237/1000], Loss: 0.0615 Epoch [238/1000], Loss: 0.0614 Epoch [239/1000], Loss: 0.0613 Epoch [240/1000], Loss: 0.0611 Epoch [241/1000], Loss: 0.0609 Epoch [242/1000], Loss: 0.0608 Epoch [243/1000], Loss: 0.0607 Epoch [244/1000], Loss: 0.0605 Epoch [245/1000], Loss: 0.0604 Epoch [246/1000], Loss: 0.0602 Epoch [247/1000], Loss: 0.0601 Epoch [248/1000], Loss: 0.0600 Epoch [249/1000], Loss: 0.0599 Epoch [250/1000], Loss: 0.0598 Epoch [251/1000], Loss: 0.0598 Epoch [252/1000], Loss: 0.0597 Epoch [253/1000], Loss: 0.0595 Epoch [254/1000], Loss: 0.0594 Epoch [255/1000], Loss: 0.0591 Epoch [256/1000], Loss: 0.0591 Epoch [257/1000], Loss: 0.0590 Epoch [258/1000], Loss: 0.0588 Epoch [259/1000], Loss: 0.0587 Epoch [260/1000], Loss: 0.0585 Epoch [261/1000], Loss: 0.0585 Epoch [262/1000], Loss: 0.0582 Epoch [263/1000], Loss: 0.0582 Epoch [264/1000], Loss: 0.0581 Epoch [265/1000], Loss: 0.0580 Epoch [266/1000], Loss: 0.0578 Epoch [267/1000], Loss: 0.0577 Epoch [268/1000], Loss: 0.0576 Epoch [269/1000], Loss: 0.0575 Epoch [270/1000], Loss: 0.0574 Epoch [271/1000], Loss: 0.0573 Epoch [272/1000], Loss: 0.0572 Epoch [273/1000], Loss: 0.0571 Epoch [274/1000], Loss: 0.0570 Epoch [275/1000], Loss: 0.0569 Epoch [276/1000], Loss: 0.0567 Epoch [277/1000], Loss: 0.0567 Epoch [278/1000], Loss: 0.0565 Epoch [279/1000], Loss: 0.0565 Epoch [280/1000], Loss: 0.0564 Epoch [281/1000], Loss: 0.0562 Epoch [282/1000], Loss: 0.0561 Epoch [283/1000], Loss: 0.0560 Epoch [284/1000], Loss: 0.0560 Epoch [285/1000], Loss: 0.0558 Epoch [286/1000], Loss: 0.0558 Epoch [287/1000], Loss: 0.0556 Epoch [288/1000], Loss: 0.0555 Epoch [289/1000], Loss: 0.0554 Epoch [290/1000], Loss: 0.0553 Epoch [291/1000], Loss: 0.0552 Epoch [292/1000], Loss: 0.0551 Epoch [293/1000], Loss: 0.0550 Epoch [294/1000], Loss: 0.0549 Epoch [295/1000], Loss: 0.0548 Epoch [296/1000], Loss: 0.0547 Epoch [297/1000], Loss: 0.0545 Epoch [298/1000], Loss: 0.0544 Epoch [299/1000], Loss: 0.0544 Epoch [300/1000], Loss: 0.0543 Epoch [301/1000], Loss: 0.0541 Epoch [302/1000], Loss: 0.0540 Epoch [303/1000], Loss: 0.0539 Epoch [304/1000], Loss: 0.0538 Epoch [305/1000], Loss: 0.0537 Epoch [306/1000], Loss: 0.0536 Epoch [307/1000], Loss: 0.0535 Epoch [308/1000], Loss: 0.0534 Epoch [309/1000], Loss: 0.0533 Epoch [310/1000], Loss: 0.0532 Epoch [311/1000], Loss: 0.0531 Epoch [312/1000], Loss: 0.0530 Epoch [313/1000], Loss: 0.0529 Epoch [314/1000], Loss: 0.0529 Epoch [315/1000], Loss: 0.0527 Epoch [316/1000], Loss: 0.0527 Epoch [317/1000], Loss: 0.0526 Epoch [318/1000], Loss: 0.0525 Epoch [319/1000], Loss: 0.0524 Epoch [320/1000], Loss: 0.0523 Epoch [321/1000], Loss: 0.0523 Epoch [322/1000], Loss: 0.0521 Epoch [323/1000], Loss: 0.0521 Epoch [324/1000], Loss: 0.0520 Epoch [325/1000], Loss: 0.0519 Epoch [326/1000], Loss: 0.0518 Epoch [327/1000], Loss: 0.0518 Epoch [328/1000], Loss: 0.0517 Epoch [329/1000], Loss: 0.0516 Epoch [330/1000], Loss: 0.0515 Epoch [331/1000], Loss: 0.0515 Epoch [332/1000], Loss: 0.0514 Epoch [333/1000], Loss: 0.0513 Epoch [334/1000], Loss: 0.0513 Epoch [335/1000], Loss: 0.0512 Epoch [336/1000], Loss: 0.0511 Epoch [337/1000], Loss: 0.0511 Epoch [338/1000], Loss: 0.0510 Epoch [339/1000], Loss: 0.0510 Epoch [340/1000], Loss: 0.0509 Epoch [341/1000], Loss: 0.0508 Epoch [342/1000], Loss: 0.0507 Epoch [343/1000], Loss: 0.0507 Epoch [344/1000], Loss: 0.0506 Epoch [345/1000], Loss: 0.0505 Epoch [346/1000], Loss: 0.0505 Epoch [347/1000], Loss: 0.0504 Epoch [348/1000], Loss: 0.0503 Epoch [349/1000], Loss: 0.0503 Epoch [350/1000], Loss: 0.0502 Epoch [351/1000], Loss: 0.0501 Epoch [352/1000], Loss: 0.0501 Epoch [353/1000], Loss: 0.0500 Epoch [354/1000], Loss: 0.0500 Epoch [355/1000], Loss: 0.0499 Epoch [356/1000], Loss: 0.0499 Epoch [357/1000], Loss: 0.0498 Epoch [358/1000], Loss: 0.0497 Epoch [359/1000], Loss: 0.0496 Epoch [360/1000], Loss: 0.0496 Epoch [361/1000], Loss: 0.0495 Epoch [362/1000], Loss: 0.0495 Epoch [363/1000], Loss: 0.0494 Epoch [364/1000], Loss: 0.0494 Epoch [365/1000], Loss: 0.0493 Epoch [366/1000], Loss: 0.0493 Epoch [367/1000], Loss: 0.0492 Epoch [368/1000], Loss: 0.0492 Epoch [369/1000], Loss: 0.0491 Epoch [370/1000], Loss: 0.0492 Epoch [371/1000], Loss: 0.0491 Epoch [372/1000], Loss: 0.0490 Epoch [373/1000], Loss: 0.0490 Epoch [374/1000], Loss: 0.0489 Epoch [375/1000], Loss: 0.0489 Epoch [376/1000], Loss: 0.0489 Epoch [377/1000], Loss: 0.0488 Epoch [378/1000], Loss: 0.0487 Epoch [379/1000], Loss: 0.0486 Epoch [380/1000], Loss: 0.0486 Epoch [381/1000], Loss: 0.0485 Epoch [382/1000], Loss: 0.0485 Epoch [383/1000], Loss: 0.0484 Epoch [384/1000], Loss: 0.0484 Epoch [385/1000], Loss: 0.0483 Epoch [386/1000], Loss: 0.0483 Epoch [387/1000], Loss: 0.0482 Epoch [388/1000], Loss: 0.0482 Epoch [389/1000], Loss: 0.0482 Epoch [390/1000], Loss: 0.0481 Epoch [391/1000], Loss: 0.0481 Epoch [392/1000], Loss: 0.0480 Epoch [393/1000], Loss: 0.0480 Epoch [394/1000], Loss: 0.0479 Epoch [395/1000], Loss: 0.0478 Epoch [396/1000], Loss: 0.0478 Epoch [397/1000], Loss: 0.0477 Epoch [398/1000], Loss: 0.0476 Epoch [399/1000], Loss: 0.0476 Epoch [400/1000], Loss: 0.0476 Epoch [401/1000], Loss: 0.0476 Epoch [402/1000], Loss: 0.0475 Epoch [403/1000], Loss: 0.0475 Epoch [404/1000], Loss: 0.0474 Epoch [405/1000], Loss: 0.0474 Epoch [406/1000], Loss: 0.0473 Epoch [407/1000], Loss: 0.0472 Epoch [408/1000], Loss: 0.0472 Epoch [409/1000], Loss: 0.0471 Epoch [410/1000], Loss: 0.0471 Epoch [411/1000], Loss: 0.0470 Epoch [412/1000], Loss: 0.0470 Epoch [413/1000], Loss: 0.0470 Epoch [414/1000], Loss: 0.0469 Epoch [415/1000], Loss: 0.0469 Epoch [416/1000], Loss: 0.0468 Epoch [417/1000], Loss: 0.0468 Epoch [418/1000], Loss: 0.0467 Epoch [419/1000], Loss: 0.0466 Epoch [420/1000], Loss: 0.0466 Epoch [421/1000], Loss: 0.0465 Epoch [422/1000], Loss: 0.0464 Epoch [423/1000], Loss: 0.0464 Epoch [424/1000], Loss: 0.0464 Epoch [425/1000], Loss: 0.0463 Epoch [426/1000], Loss: 0.0462 Epoch [427/1000], Loss: 0.0462 Epoch [428/1000], Loss: 0.0461 Epoch [429/1000], Loss: 0.0461 Epoch [430/1000], Loss: 0.0461 Epoch [431/1000], Loss: 0.0460 Epoch [432/1000], Loss: 0.0460 Epoch [433/1000], Loss: 0.0459 Epoch [434/1000], Loss: 0.0459 Epoch [435/1000], Loss: 0.0459 Epoch [436/1000], Loss: 0.0460 Epoch [437/1000], Loss: 0.0458 Epoch [438/1000], Loss: 0.0460 Epoch [439/1000], Loss: 0.0459 Epoch [440/1000], Loss: 0.0458 Epoch [441/1000], Loss: 0.0456 Epoch [442/1000], Loss: 0.0456 Epoch [443/1000], Loss: 0.0457 Epoch [444/1000], Loss: 0.0455 Epoch [445/1000], Loss: 0.0456 Epoch [446/1000], Loss: 0.0455 Epoch [447/1000], Loss: 0.0455 Epoch [448/1000], Loss: 0.0454 Epoch [449/1000], Loss: 0.0455 Epoch [450/1000], Loss: 0.0454 Epoch [451/1000], Loss: 0.0454 Epoch [452/1000], Loss: 0.0453 Epoch [453/1000], Loss: 0.0453 Epoch [454/1000], Loss: 0.0452 Epoch [455/1000], Loss: 0.0452 Epoch [456/1000], Loss: 0.0451 Epoch [457/1000], Loss: 0.0451 Epoch [458/1000], Loss: 0.0451 Epoch [459/1000], Loss: 0.0450 Epoch [460/1000], Loss: 0.0451 Epoch [461/1000], Loss: 0.0450 Epoch [462/1000], Loss: 0.0449 Epoch [463/1000], Loss: 0.0448 Epoch [464/1000], Loss: 0.0449 Epoch [465/1000], Loss: 0.0448 Epoch [466/1000], Loss: 0.0448 Epoch [467/1000], Loss: 0.0448 Epoch [468/1000], Loss: 0.0447 Epoch [469/1000], Loss: 0.0448 Epoch [470/1000], Loss: 0.0447 Epoch [471/1000], Loss: 0.0448 Epoch [472/1000], Loss: 0.0447 Epoch [473/1000], Loss: 0.0446 Epoch [474/1000], Loss: 0.0445 Epoch [475/1000], Loss: 0.0444 Epoch [476/1000], Loss: 0.0444 Epoch [477/1000], Loss: 0.0444 Epoch [478/1000], Loss: 0.0444 Epoch [479/1000], Loss: 0.0443 Epoch [480/1000], Loss: 0.0442 Epoch [481/1000], Loss: 0.0442 Epoch [482/1000], Loss: 0.0442 Epoch [483/1000], Loss: 0.0441 Epoch [484/1000], Loss: 0.0441 Epoch [485/1000], Loss: 0.0441 Epoch [486/1000], Loss: 0.0440 Epoch [487/1000], Loss: 0.0440 Epoch [488/1000], Loss: 0.0439 Epoch [489/1000], Loss: 0.0440 Epoch [490/1000], Loss: 0.0439 Epoch [491/1000], Loss: 0.0440 Epoch [492/1000], Loss: 0.0440 Epoch [493/1000], Loss: 0.0439 Epoch [494/1000], Loss: 0.0439 Epoch [495/1000], Loss: 0.0438 Epoch [496/1000], Loss: 0.0437 Epoch [497/1000], Loss: 0.0437 Epoch [498/1000], Loss: 0.0436 Epoch [499/1000], Loss: 0.0436 Epoch [500/1000], Loss: 0.0436 Epoch [501/1000], Loss: 0.0436 Epoch [502/1000], Loss: 0.0436 Epoch [503/1000], Loss: 0.0435 Epoch [504/1000], Loss: 0.0435 Epoch [505/1000], Loss: 0.0435 Epoch [506/1000], Loss: 0.0435 Epoch [507/1000], Loss: 0.0434 Epoch [508/1000], Loss: 0.0434 Epoch [509/1000], Loss: 0.0434 Epoch [510/1000], Loss: 0.0435 Epoch [511/1000], Loss: 0.0435 Epoch [512/1000], Loss: 0.0433 Epoch [513/1000], Loss: 0.0434 Epoch [514/1000], Loss: 0.0435 Epoch [515/1000], Loss: 0.0433 Epoch [516/1000], Loss: 0.0434 Epoch [517/1000], Loss: 0.0434 Epoch [518/1000], Loss: 0.0433 Epoch [519/1000], Loss: 0.0433 Epoch [520/1000], Loss: 0.0432 Epoch [521/1000], Loss: 0.0432 Epoch [522/1000], Loss: 0.0431 Epoch [523/1000], Loss: 0.0431 Epoch [524/1000], Loss: 0.0431 Epoch [525/1000], Loss: 0.0431 Epoch [526/1000], Loss: 0.0431 Epoch [527/1000], Loss: 0.0429 Epoch [528/1000], Loss: 0.0429 Epoch [529/1000], Loss: 0.0429 Epoch [530/1000], Loss: 0.0429 Epoch [531/1000], Loss: 0.0428 Epoch [532/1000], Loss: 0.0428 Epoch [533/1000], Loss: 0.0427 Epoch [534/1000], Loss: 0.0427 Epoch [535/1000], Loss: 0.0427 Epoch [536/1000], Loss: 0.0427 Epoch [537/1000], Loss: 0.0427 Epoch [538/1000], Loss: 0.0426 Epoch [539/1000], Loss: 0.0426 Epoch [540/1000], Loss: 0.0426 Epoch [541/1000], Loss: 0.0425 Epoch [542/1000], Loss: 0.0425 Epoch [543/1000], Loss: 0.0424 Epoch [544/1000], Loss: 0.0424 Epoch [545/1000], Loss: 0.0424 Epoch [546/1000], Loss: 0.0425 Epoch [547/1000], Loss: 0.0424 Epoch [548/1000], Loss: 0.0424 Epoch [549/1000], Loss: 0.0423 Epoch [550/1000], Loss: 0.0422 Epoch [551/1000], Loss: 0.0422 Epoch [552/1000], Loss: 0.0422 Epoch [553/1000], Loss: 0.0422 Epoch [554/1000], Loss: 0.0422 Epoch [555/1000], Loss: 0.0421 Epoch [556/1000], Loss: 0.0421 Epoch [557/1000], Loss: 0.0421 Epoch [558/1000], Loss: 0.0421 Epoch [559/1000], Loss: 0.0420 Epoch [560/1000], Loss: 0.0420 Epoch [561/1000], Loss: 0.0420 Epoch [562/1000], Loss: 0.0420 Epoch [563/1000], Loss: 0.0419 Epoch [564/1000], Loss: 0.0420 Epoch [565/1000], Loss: 0.0420 Epoch [566/1000], Loss: 0.0419 Epoch [567/1000], Loss: 0.0419 Epoch [568/1000], Loss: 0.0419 Epoch [569/1000], Loss: 0.0419 Epoch [570/1000], Loss: 0.0419 Epoch [571/1000], Loss: 0.0419 Epoch [572/1000], Loss: 0.0418 Epoch [573/1000], Loss: 0.0418 Epoch [574/1000], Loss: 0.0417 Epoch [575/1000], Loss: 0.0419 Epoch [576/1000], Loss: 0.0417 Epoch [577/1000], Loss: 0.0418 Epoch [578/1000], Loss: 0.0417 Epoch [579/1000], Loss: 0.0416 Epoch [580/1000], Loss: 0.0417 Epoch [581/1000], Loss: 0.0416 Epoch [582/1000], Loss: 0.0416 Epoch [583/1000], Loss: 0.0416 Epoch [584/1000], Loss: 0.0416 Epoch [585/1000], Loss: 0.0416 Epoch [586/1000], Loss: 0.0416 Epoch [587/1000], Loss: 0.0416 Epoch [588/1000], Loss: 0.0416 Epoch [589/1000], Loss: 0.0415 Epoch [590/1000], Loss: 0.0415 Epoch [591/1000], Loss: 0.0414 Epoch [592/1000], Loss: 0.0414 Epoch [593/1000], Loss: 0.0414 Epoch [594/1000], Loss: 0.0414 Epoch [595/1000], Loss: 0.0414 Epoch [596/1000], Loss: 0.0413 Epoch [597/1000], Loss: 0.0413 Epoch [598/1000], Loss: 0.0413 Epoch [599/1000], Loss: 0.0413 Epoch [600/1000], Loss: 0.0413 Epoch [601/1000], Loss: 0.0412 Epoch [602/1000], Loss: 0.0412 Epoch [603/1000], Loss: 0.0412 Epoch [604/1000], Loss: 0.0412 Epoch [605/1000], Loss: 0.0412 Epoch [606/1000], Loss: 0.0412 Epoch [607/1000], Loss: 0.0412 Epoch [608/1000], Loss: 0.0412 Epoch [609/1000], Loss: 0.0411 Epoch [610/1000], Loss: 0.0411 Epoch [611/1000], Loss: 0.0410 Epoch [612/1000], Loss: 0.0410 Epoch [613/1000], Loss: 0.0410 Epoch [614/1000], Loss: 0.0409 Epoch [615/1000], Loss: 0.0409 Epoch [616/1000], Loss: 0.0409 Epoch [617/1000], Loss: 0.0409 Epoch [618/1000], Loss: 0.0409 Epoch [619/1000], Loss: 0.0409 Epoch [620/1000], Loss: 0.0408 Epoch [621/1000], Loss: 0.0408 Epoch [622/1000], Loss: 0.0408 Epoch [623/1000], Loss: 0.0408 Epoch [624/1000], Loss: 0.0408 Epoch [625/1000], Loss: 0.0407 Epoch [626/1000], Loss: 0.0407 Epoch [627/1000], Loss: 0.0407 Epoch [628/1000], Loss: 0.0406 Epoch [629/1000], Loss: 0.0406 Epoch [630/1000], Loss: 0.0406 Epoch [631/1000], Loss: 0.0406 Epoch [632/1000], Loss: 0.0406 Epoch [633/1000], Loss: 0.0405 Epoch [634/1000], Loss: 0.0405 Epoch [635/1000], Loss: 0.0405 Epoch [636/1000], Loss: 0.0404 Epoch [637/1000], Loss: 0.0404 Epoch [638/1000], Loss: 0.0403 Epoch [639/1000], Loss: 0.0403 Epoch [640/1000], Loss: 0.0402 Epoch [641/1000], Loss: 0.0403 Epoch [642/1000], Loss: 0.0403 Epoch [643/1000], Loss: 0.0403 Epoch [644/1000], Loss: 0.0402 Epoch [645/1000], Loss: 0.0402 Epoch [646/1000], Loss: 0.0401 Epoch [647/1000], Loss: 0.0401 Epoch [648/1000], Loss: 0.0401 Epoch [649/1000], Loss: 0.0401 Epoch [650/1000], Loss: 0.0401 Epoch [651/1000], Loss: 0.0401 Epoch [652/1000], Loss: 0.0401 Epoch [653/1000], Loss: 0.0401 Epoch [654/1000], Loss: 0.0400 Epoch [655/1000], Loss: 0.0400 Epoch [656/1000], Loss: 0.0400 Epoch [657/1000], Loss: 0.0399 Epoch [658/1000], Loss: 0.0399 Epoch [659/1000], Loss: 0.0399 Epoch [660/1000], Loss: 0.0399 Epoch [661/1000], Loss: 0.0399 Epoch [662/1000], Loss: 0.0399 Epoch [663/1000], Loss: 0.0399 Epoch [664/1000], Loss: 0.0399 Epoch [665/1000], Loss: 0.0398 Epoch [666/1000], Loss: 0.0398 Epoch [667/1000], Loss: 0.0398 Epoch [668/1000], Loss: 0.0398 Epoch [669/1000], Loss: 0.0398 Epoch [670/1000], Loss: 0.0398 Epoch [671/1000], Loss: 0.0398 Epoch [672/1000], Loss: 0.0397 Epoch [673/1000], Loss: 0.0397 Epoch [674/1000], Loss: 0.0396 Epoch [675/1000], Loss: 0.0396 Epoch [676/1000], Loss: 0.0396 Epoch [677/1000], Loss: 0.0396 Epoch [678/1000], Loss: 0.0396 Epoch [679/1000], Loss: 0.0396 Epoch [680/1000], Loss: 0.0395 Epoch [681/1000], Loss: 0.0395 Epoch [682/1000], Loss: 0.0394 Epoch [683/1000], Loss: 0.0394 Epoch [684/1000], Loss: 0.0394 Epoch [685/1000], Loss: 0.0393 Epoch [686/1000], Loss: 0.0393 Epoch [687/1000], Loss: 0.0393 Epoch [688/1000], Loss: 0.0393 Epoch [689/1000], Loss: 0.0393 Epoch [690/1000], Loss: 0.0393 Epoch [691/1000], Loss: 0.0393 Epoch [692/1000], Loss: 0.0394 Epoch [693/1000], Loss: 0.0393 Epoch [694/1000], Loss: 0.0394 Epoch [695/1000], Loss: 0.0395 Epoch [696/1000], Loss: 0.0395 Epoch [697/1000], Loss: 0.0394 Epoch [698/1000], Loss: 0.0394 Epoch [699/1000], Loss: 0.0393 Epoch [700/1000], Loss: 0.0393 Epoch [701/1000], Loss: 0.0393 Epoch [702/1000], Loss: 0.0393 Epoch [703/1000], Loss: 0.0392 Epoch [704/1000], Loss: 0.0391 Epoch [705/1000], Loss: 0.0391 Epoch [706/1000], Loss: 0.0392 Epoch [707/1000], Loss: 0.0392 Epoch [708/1000], Loss: 0.0391 Epoch [709/1000], Loss: 0.0390 Epoch [710/1000], Loss: 0.0390 Epoch [711/1000], Loss: 0.0389 Epoch [712/1000], Loss: 0.0389 Epoch [713/1000], Loss: 0.0390 Epoch [714/1000], Loss: 0.0390 Epoch [715/1000], Loss: 0.0390 Epoch [716/1000], Loss: 0.0390 Epoch [717/1000], Loss: 0.0390 Epoch [718/1000], Loss: 0.0389 Epoch [719/1000], Loss: 0.0389 Epoch [720/1000], Loss: 0.0388 Epoch [721/1000], Loss: 0.0388 Epoch [722/1000], Loss: 0.0388 Epoch [723/1000], Loss: 0.0388 Epoch [724/1000], Loss: 0.0388 Epoch [725/1000], Loss: 0.0387 Epoch [726/1000], Loss: 0.0387 Epoch [727/1000], Loss: 0.0387 Epoch [728/1000], Loss: 0.0387 Epoch [729/1000], Loss: 0.0387 Epoch [730/1000], Loss: 0.0387 Epoch [731/1000], Loss: 0.0386 Epoch [732/1000], Loss: 0.0385 Epoch [733/1000], Loss: 0.0385 Epoch [734/1000], Loss: 0.0385 Epoch [735/1000], Loss: 0.0385 Epoch [736/1000], Loss: 0.0385 Epoch [737/1000], Loss: 0.0385 Epoch [738/1000], Loss: 0.0385 Epoch [739/1000], Loss: 0.0385 Epoch [740/1000], Loss: 0.0385 Epoch [741/1000], Loss: 0.0385 Epoch [742/1000], Loss: 0.0385 Epoch [743/1000], Loss: 0.0384 Epoch [744/1000], Loss: 0.0384 Epoch [745/1000], Loss: 0.0384 Epoch [746/1000], Loss: 0.0383 Epoch [747/1000], Loss: 0.0383 Epoch [748/1000], Loss: 0.0383 Epoch [749/1000], Loss: 0.0383 Epoch [750/1000], Loss: 0.0383 Epoch [751/1000], Loss: 0.0382 Epoch [752/1000], Loss: 0.0382 Epoch [753/1000], Loss: 0.0382 Epoch [754/1000], Loss: 0.0382 Epoch [755/1000], Loss: 0.0382 Epoch [756/1000], Loss: 0.0382 Epoch [757/1000], Loss: 0.0382 Epoch [758/1000], Loss: 0.0381 Epoch [759/1000], Loss: 0.0381 Epoch [760/1000], Loss: 0.0381 Epoch [761/1000], Loss: 0.0381 Epoch [762/1000], Loss: 0.0382 Epoch [763/1000], Loss: 0.0383 Epoch [764/1000], Loss: 0.0381 Epoch [765/1000], Loss: 0.0381 Epoch [766/1000], Loss: 0.0381 Epoch [767/1000], Loss: 0.0380 Epoch [768/1000], Loss: 0.0381 Epoch [769/1000], Loss: 0.0381 Epoch [770/1000], Loss: 0.0381 Epoch [771/1000], Loss: 0.0381 Epoch [772/1000], Loss: 0.0381 Epoch [773/1000], Loss: 0.0380 Epoch [774/1000], Loss: 0.0380 Epoch [775/1000], Loss: 0.0380 Epoch [776/1000], Loss: 0.0380 Epoch [777/1000], Loss: 0.0379 Epoch [778/1000], Loss: 0.0379 Epoch [779/1000], Loss: 0.0379 Epoch [780/1000], Loss: 0.0379 Epoch [781/1000], Loss: 0.0379 Epoch [782/1000], Loss: 0.0379 Epoch [783/1000], Loss: 0.0379 Epoch [784/1000], Loss: 0.0379 Epoch [785/1000], Loss: 0.0378 Epoch [786/1000], Loss: 0.0377 Epoch [787/1000], Loss: 0.0377 Epoch [788/1000], Loss: 0.0377 Epoch [789/1000], Loss: 0.0377 Epoch [790/1000], Loss: 0.0377 Epoch [791/1000], Loss: 0.0377 Epoch [792/1000], Loss: 0.0378 Epoch [793/1000], Loss: 0.0377 Epoch [794/1000], Loss: 0.0377 Epoch [795/1000], Loss: 0.0377 Epoch [796/1000], Loss: 0.0376 Epoch [797/1000], Loss: 0.0377 Epoch [798/1000], Loss: 0.0377 Epoch [799/1000], Loss: 0.0377 Epoch [800/1000], Loss: 0.0376 Epoch [801/1000], Loss: 0.0377 Epoch [802/1000], Loss: 0.0377 Epoch [803/1000], Loss: 0.0377 Epoch [804/1000], Loss: 0.0376 Epoch [805/1000], Loss: 0.0377 Epoch [806/1000], Loss: 0.0377 Epoch [807/1000], Loss: 0.0377 Epoch [808/1000], Loss: 0.0377 Epoch [809/1000], Loss: 0.0376 Epoch [810/1000], Loss: 0.0376 Epoch [811/1000], Loss: 0.0376 Epoch [812/1000], Loss: 0.0376 Epoch [813/1000], Loss: 0.0375 Epoch [814/1000], Loss: 0.0375 Epoch [815/1000], Loss: 0.0374 Epoch [816/1000], Loss: 0.0374 Epoch [817/1000], Loss: 0.0374 Epoch [818/1000], Loss: 0.0374 Epoch [819/1000], Loss: 0.0374 Epoch [820/1000], Loss: 0.0374 Epoch [821/1000], Loss: 0.0374 Epoch [822/1000], Loss: 0.0374 Epoch [823/1000], Loss: 0.0374 Epoch [824/1000], Loss: 0.0374 Epoch [825/1000], Loss: 0.0374 Epoch [826/1000], Loss: 0.0375 Epoch [827/1000], Loss: 0.0376 Epoch [828/1000], Loss: 0.0375 Epoch [829/1000], Loss: 0.0374 Epoch [830/1000], Loss: 0.0373 Epoch [831/1000], Loss: 0.0373 Epoch [832/1000], Loss: 0.0373 Epoch [833/1000], Loss: 0.0373 Epoch [834/1000], Loss: 0.0374 Epoch [835/1000], Loss: 0.0373 Epoch [836/1000], Loss: 0.0373 Epoch [837/1000], Loss: 0.0373 Epoch [838/1000], Loss: 0.0373 Epoch [839/1000], Loss: 0.0373 Epoch [840/1000], Loss: 0.0373 Epoch [841/1000], Loss: 0.0372 Epoch [842/1000], Loss: 0.0371 Epoch [843/1000], Loss: 0.0371 Epoch [844/1000], Loss: 0.0371 Epoch [845/1000], Loss: 0.0372 Epoch [846/1000], Loss: 0.0372 Epoch [847/1000], Loss: 0.0373 Epoch [848/1000], Loss: 0.0372 Epoch [849/1000], Loss: 0.0372 Epoch [850/1000], Loss: 0.0371 Epoch [851/1000], Loss: 0.0370 Epoch [852/1000], Loss: 0.0370 Epoch [853/1000], Loss: 0.0370 Epoch [854/1000], Loss: 0.0370 Epoch [855/1000], Loss: 0.0370 Epoch [856/1000], Loss: 0.0370 Epoch [857/1000], Loss: 0.0370 Epoch [858/1000], Loss: 0.0370 Epoch [859/1000], Loss: 0.0370 Epoch [860/1000], Loss: 0.0370 Epoch [861/1000], Loss: 0.0370 Epoch [862/1000], Loss: 0.0369 Epoch [863/1000], Loss: 0.0369 Epoch [864/1000], Loss: 0.0369 Epoch [865/1000], Loss: 0.0369 Epoch [866/1000], Loss: 0.0369 Epoch [867/1000], Loss: 0.0369 Epoch [868/1000], Loss: 0.0369 Epoch [869/1000], Loss: 0.0369 Epoch [870/1000], Loss: 0.0369 Epoch [871/1000], Loss: 0.0369 Epoch [872/1000], Loss: 0.0368 Epoch [873/1000], Loss: 0.0368 Epoch [874/1000], Loss: 0.0368 Epoch [875/1000], Loss: 0.0368 Epoch [876/1000], Loss: 0.0368 Epoch [877/1000], Loss: 0.0367 Epoch [878/1000], Loss: 0.0367 Epoch [879/1000], Loss: 0.0367 Epoch [880/1000], Loss: 0.0368 Epoch [881/1000], Loss: 0.0368 Epoch [882/1000], Loss: 0.0368 Epoch [883/1000], Loss: 0.0368 Epoch [884/1000], Loss: 0.0368 Epoch [885/1000], Loss: 0.0368 Epoch [886/1000], Loss: 0.0367 Epoch [887/1000], Loss: 0.0367 Epoch [888/1000], Loss: 0.0367 Epoch [889/1000], Loss: 0.0370 Epoch [890/1000], Loss: 0.0370 Epoch [891/1000], Loss: 0.0369 Epoch [892/1000], Loss: 0.0366 Epoch [893/1000], Loss: 0.0367 Epoch [894/1000], Loss: 0.0368 Epoch [895/1000], Loss: 0.0366 Epoch [896/1000], Loss: 0.0366 Epoch [897/1000], Loss: 0.0367 Epoch [898/1000], Loss: 0.0367 Epoch [899/1000], Loss: 0.0366 Epoch [900/1000], Loss: 0.0366 Epoch [901/1000], Loss: 0.0366 Epoch [902/1000], Loss: 0.0365 Epoch [903/1000], Loss: 0.0365 Epoch [904/1000], Loss: 0.0366 Epoch [905/1000], Loss: 0.0366 Epoch [906/1000], Loss: 0.0366 Epoch [907/1000], Loss: 0.0366 Epoch [908/1000], Loss: 0.0366 Epoch [909/1000], Loss: 0.0367 Epoch [910/1000], Loss: 0.0365 Epoch [911/1000], Loss: 0.0365 Epoch [912/1000], Loss: 0.0364 Epoch [913/1000], Loss: 0.0365 Epoch [914/1000], Loss: 0.0365 Epoch [915/1000], Loss: 0.0364 Epoch [916/1000], Loss: 0.0364 Epoch [917/1000], Loss: 0.0364 Epoch [918/1000], Loss: 0.0364 Epoch [919/1000], Loss: 0.0364 Epoch [920/1000], Loss: 0.0363 Epoch [921/1000], Loss: 0.0363 Epoch [922/1000], Loss: 0.0363 Epoch [923/1000], Loss: 0.0363 Epoch [924/1000], Loss: 0.0363 Epoch [925/1000], Loss: 0.0363 Epoch [926/1000], Loss: 0.0363 Epoch [927/1000], Loss: 0.0363 Epoch [928/1000], Loss: 0.0363 Epoch [929/1000], Loss: 0.0363 Epoch [930/1000], Loss: 0.0362 Epoch [931/1000], Loss: 0.0362 Epoch [932/1000], Loss: 0.0362 Epoch [933/1000], Loss: 0.0362 Epoch [934/1000], Loss: 0.0362 Epoch [935/1000], Loss: 0.0362 Epoch [936/1000], Loss: 0.0362 Epoch [937/1000], Loss: 0.0362 Epoch [938/1000], Loss: 0.0362 Epoch [939/1000], Loss: 0.0362 Epoch [940/1000], Loss: 0.0362 Epoch [941/1000], Loss: 0.0362 Epoch [942/1000], Loss: 0.0362 Epoch [943/1000], Loss: 0.0361 Epoch [944/1000], Loss: 0.0362 Epoch [945/1000], Loss: 0.0362 Epoch [946/1000], Loss: 0.0363 Epoch [947/1000], Loss: 0.0363 Epoch [948/1000], Loss: 0.0363 Epoch [949/1000], Loss: 0.0362 Epoch [950/1000], Loss: 0.0361 Epoch [951/1000], Loss: 0.0360 Epoch [952/1000], Loss: 0.0360 Epoch [953/1000], Loss: 0.0361 Epoch [954/1000], Loss: 0.0361 Epoch [955/1000], Loss: 0.0361 Epoch [956/1000], Loss: 0.0361 Epoch [957/1000], Loss: 0.0360 Epoch [958/1000], Loss: 0.0360 Epoch [959/1000], Loss: 0.0361 Epoch [960/1000], Loss: 0.0361 Epoch [961/1000], Loss: 0.0362 Epoch [962/1000], Loss: 0.0361 Epoch [963/1000], Loss: 0.0361 Epoch [964/1000], Loss: 0.0360 Epoch [965/1000], Loss: 0.0360 Epoch [966/1000], Loss: 0.0360 Epoch [967/1000], Loss: 0.0360 Epoch [968/1000], Loss: 0.0360 Epoch [969/1000], Loss: 0.0361 Epoch [970/1000], Loss: 0.0360 Epoch [971/1000], Loss: 0.0360 Epoch [972/1000], Loss: 0.0360 Epoch [973/1000], Loss: 0.0360 Epoch [974/1000], Loss: 0.0360 Epoch [975/1000], Loss: 0.0360 Epoch [976/1000], Loss: 0.0359 Epoch [977/1000], Loss: 0.0359 Epoch [978/1000], Loss: 0.0359 Epoch [979/1000], Loss: 0.0359 Epoch [980/1000], Loss: 0.0359 Epoch [981/1000], Loss: 0.0359 Epoch [982/1000], Loss: 0.0359 Epoch [983/1000], Loss: 0.0358 Epoch [984/1000], Loss: 0.0358 Epoch [985/1000], Loss: 0.0358 Epoch [986/1000], Loss: 0.0358 Epoch [987/1000], Loss: 0.0358 Epoch [988/1000], Loss: 0.0358 Epoch [989/1000], Loss: 0.0358 Epoch [990/1000], Loss: 0.0358 Epoch [991/1000], Loss: 0.0357 Epoch [992/1000], Loss: 0.0357 Epoch [993/1000], Loss: 0.0357 Epoch [994/1000], Loss: 0.0357 Epoch [995/1000], Loss: 0.0358 Epoch [996/1000], Loss: 0.0359 Epoch [997/1000], Loss: 0.0360 Epoch [998/1000], Loss: 0.0359 Epoch [999/1000], Loss: 0.0358 Epoch [1000/1000], Loss: 0.0357
class PointModel(nn.Module):
def __init__(self, n, use_cuda=True):
super(PointModel, self).__init__()
self.num = n
self.use_cuda = use_cuda
self.posx = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
self.posy = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
def forward(self, isize):
posx = self.posx
posy = self.posy
X = torch.unsqueeze(torch.arange(
0.5, isize + 0.5, 1) / isize, 0)
Y = torch.unsqueeze(torch.arange(
0.5, isize + 0.5, 1) / isize, 0)
I = torch.unsqueeze(torch.ones(isize), 0)
if self.use_cuda:
X = X.cuda()
Y = Y.cuda()
I = I.cuda()
X = X * I
Y = torch.transpose(Y * I, 0, 1)
X = X.unsqueeze_(0)
Y = Y.unsqueeze_(0)
X = X.expand(self.num, 1, isize, isize) - \
posx.reshape(self.num, 1, 1, 1)
Y = Y.expand(self.num, 1, isize, isize) - \
posy.reshape(self.num, 1, 1, 1)
R = torch.sqrt(X.square() + Y.square())
sharpness = float(1 << 9)
ir = 0.5 / float(isize)
filters = torch.exp(-R / ir)
return (filters)
num = 1 << 12
model = PointModel(num, use_cuda=True)
model = model.cuda()
optimizer = optim.AdamW(model.parameters(), lr=0.005)
out = None
try:
shutil.rmtree('.scratch')
except:
pass
os.mkdir('.scratch')
def brightness(val):
return torch.sqrt(0.241*(val[0]**2) + 0.691*(val[1]**2) + 0.068*(val[2]**2))
for epoch in range(0, num_epochs):
with torch.amp.autocast(device_type="cuda", dtype=torch.float16):
torch.cuda.empty_cache()
filters = model(isize)
bg = torch.tensor([1.0]).expand(3, isize, isize).cuda() * torch.exp(-4. * (torch.sum(filters.expand(num, 1, isize, isize), (0))))
out = bg.cuda()
pic_loss = (((( (img-out) ).square()))).mean().sqrt()
loss = pic_loss
optimizer.zero_grad()
loss.backward()
optimizer.step()
im = out.clamp(0.0, 1.0).detach().permute(1,2,0).cpu().numpy()
plt.imsave(".scratch/out_" + str(epoch) + ".png", im)
print(f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}')
torch.save(model.state_dict(), 'model.ckpt')
Epoch [1/1000], Loss: 0.4229 Epoch [2/1000], Loss: 0.3966 Epoch [3/1000], Loss: 0.3821 Epoch [4/1000], Loss: 0.3734 Epoch [5/1000], Loss: 0.3673 Epoch [6/1000], Loss: 0.3627 Epoch [7/1000], Loss: 0.3589 Epoch [8/1000], Loss: 0.3555 Epoch [9/1000], Loss: 0.3524 Epoch [10/1000], Loss: 0.3498 Epoch [11/1000], Loss: 0.3477 Epoch [12/1000], Loss: 0.3455 Epoch [13/1000], Loss: 0.3435 Epoch [14/1000], Loss: 0.3419 Epoch [15/1000], Loss: 0.3405 Epoch [16/1000], Loss: 0.3391 Epoch [17/1000], Loss: 0.3379 Epoch [18/1000], Loss: 0.3367 Epoch [19/1000], Loss: 0.3357 Epoch [20/1000], Loss: 0.3348 Epoch [21/1000], Loss: 0.3339 Epoch [22/1000], Loss: 0.3331 Epoch [23/1000], Loss: 0.3323 Epoch [24/1000], Loss: 0.3316 Epoch [25/1000], Loss: 0.3310 Epoch [26/1000], Loss: 0.3304 Epoch [27/1000], Loss: 0.3298 Epoch [28/1000], Loss: 0.3293 Epoch [29/1000], Loss: 0.3288 Epoch [30/1000], Loss: 0.3283 Epoch [31/1000], Loss: 0.3280 Epoch [32/1000], Loss: 0.3276 Epoch [33/1000], Loss: 0.3271 Epoch [34/1000], Loss: 0.3267 Epoch [35/1000], Loss: 0.3265 Epoch [36/1000], Loss: 0.3262 Epoch [37/1000], Loss: 0.3259 Epoch [38/1000], Loss: 0.3256 Epoch [39/1000], Loss: 0.3253 Epoch [40/1000], Loss: 0.3251 Epoch [41/1000], Loss: 0.3249 Epoch [42/1000], Loss: 0.3246 Epoch [43/1000], Loss: 0.3244 Epoch [44/1000], Loss: 0.3242 Epoch [45/1000], Loss: 0.3240 Epoch [46/1000], Loss: 0.3238 Epoch [47/1000], Loss: 0.3237 Epoch [48/1000], Loss: 0.3235 Epoch [49/1000], Loss: 0.3234 Epoch [50/1000], Loss: 0.3233 Epoch [51/1000], Loss: 0.3232 Epoch [52/1000], Loss: 0.3230 Epoch [53/1000], Loss: 0.3229 Epoch [54/1000], Loss: 0.3228 Epoch [55/1000], Loss: 0.3227 Epoch [56/1000], Loss: 0.3226 Epoch [57/1000], Loss: 0.3225 Epoch [58/1000], Loss: 0.3224 Epoch [59/1000], Loss: 0.3223 Epoch [60/1000], Loss: 0.3223 Epoch [61/1000], Loss: 0.3222 Epoch [62/1000], Loss: 0.3221 Epoch [63/1000], Loss: 0.3221 Epoch [64/1000], Loss: 0.3221 Epoch [65/1000], Loss: 0.3220 Epoch [66/1000], Loss: 0.3220 Epoch [67/1000], Loss: 0.3219 Epoch [68/1000], Loss: 0.3219 Epoch [69/1000], Loss: 0.3219 Epoch [70/1000], Loss: 0.3218 Epoch [71/1000], Loss: 0.3218 Epoch [72/1000], Loss: 0.3218 Epoch [73/1000], Loss: 0.3217 Epoch [74/1000], Loss: 0.3217 Epoch [75/1000], Loss: 0.3217 Epoch [76/1000], Loss: 0.3217 Epoch [77/1000], Loss: 0.3216 Epoch [78/1000], Loss: 0.3216 Epoch [79/1000], Loss: 0.3216 Epoch [80/1000], Loss: 0.3216 Epoch [81/1000], Loss: 0.3216 Epoch [82/1000], Loss: 0.3216 Epoch [83/1000], Loss: 0.3215 Epoch [84/1000], Loss: 0.3215 Epoch [85/1000], Loss: 0.3215 Epoch [86/1000], Loss: 0.3215 Epoch [87/1000], Loss: 0.3215 Epoch [88/1000], Loss: 0.3215 Epoch [89/1000], Loss: 0.3215 Epoch [90/1000], Loss: 0.3215 Epoch [91/1000], Loss: 0.3214 Epoch [92/1000], Loss: 0.3214 Epoch [93/1000], Loss: 0.3214 Epoch [94/1000], Loss: 0.3214 Epoch [95/1000], Loss: 0.3214 Epoch [96/1000], Loss: 0.3214 Epoch [97/1000], Loss: 0.3214 Epoch [98/1000], Loss: 0.3214 Epoch [99/1000], Loss: 0.3214 Epoch [100/1000], Loss: 0.3214 Epoch [101/1000], Loss: 0.3214 Epoch [102/1000], Loss: 0.3214 Epoch [103/1000], Loss: 0.3214 Epoch [104/1000], Loss: 0.3214 Epoch [105/1000], Loss: 0.3214 Epoch [106/1000], Loss: 0.3214 Epoch [107/1000], Loss: 0.3213 Epoch [108/1000], Loss: 0.3213 Epoch [109/1000], Loss: 0.3213 Epoch [110/1000], Loss: 0.3213 Epoch [111/1000], Loss: 0.3213 Epoch [112/1000], Loss: 0.3213 Epoch [113/1000], Loss: 0.3213 Epoch [114/1000], Loss: 0.3213 Epoch [115/1000], Loss: 0.3213 Epoch [116/1000], Loss: 0.3213 Epoch [117/1000], Loss: 0.3213 Epoch [118/1000], Loss: 0.3213 Epoch [119/1000], Loss: 0.3213 Epoch [120/1000], Loss: 0.3213 Epoch [121/1000], Loss: 0.3213 Epoch [122/1000], Loss: 0.3213 Epoch [123/1000], Loss: 0.3213 Epoch [124/1000], Loss: 0.3213 Epoch [125/1000], Loss: 0.3213 Epoch [126/1000], Loss: 0.3213 Epoch [127/1000], Loss: 0.3213 Epoch [128/1000], Loss: 0.3213 Epoch [129/1000], Loss: 0.3213 Epoch [130/1000], Loss: 0.3213 Epoch [131/1000], Loss: 0.3212 Epoch [132/1000], Loss: 0.3212 Epoch [133/1000], Loss: 0.3212 Epoch [134/1000], Loss: 0.3212 Epoch [135/1000], Loss: 0.3212 Epoch [136/1000], Loss: 0.3212 Epoch [137/1000], Loss: 0.3212 Epoch [138/1000], Loss: 0.3212 Epoch [139/1000], Loss: 0.3212 Epoch [140/1000], Loss: 0.3212 Epoch [141/1000], Loss: 0.3212 Epoch [142/1000], Loss: 0.3211 Epoch [143/1000], Loss: 0.3212 Epoch [144/1000], Loss: 0.3211 Epoch [145/1000], Loss: 0.3211 Epoch [146/1000], Loss: 0.3211 Epoch [147/1000], Loss: 0.3211 Epoch [148/1000], Loss: 0.3211 Epoch [149/1000], Loss: 0.3211 Epoch [150/1000], Loss: 0.3211 Epoch [151/1000], Loss: 0.3211 Epoch [152/1000], Loss: 0.3211 Epoch [153/1000], Loss: 0.3211 Epoch [154/1000], Loss: 0.3211 Epoch [155/1000], Loss: 0.3211 Epoch [156/1000], Loss: 0.3211 Epoch [157/1000], Loss: 0.3211 Epoch [158/1000], Loss: 0.3211 Epoch [159/1000], Loss: 0.3211 Epoch [160/1000], Loss: 0.3211 Epoch [161/1000], Loss: 0.3211 Epoch [162/1000], Loss: 0.3211 Epoch [163/1000], Loss: 0.3211 Epoch [164/1000], Loss: 0.3211 Epoch [165/1000], Loss: 0.3210 Epoch [166/1000], Loss: 0.3210 Epoch [167/1000], Loss: 0.3210 Epoch [168/1000], Loss: 0.3210 Epoch [169/1000], Loss: 0.3210 Epoch [170/1000], Loss: 0.3210 Epoch [171/1000], Loss: 0.3210 Epoch [172/1000], Loss: 0.3210 Epoch [173/1000], Loss: 0.3210 Epoch [174/1000], Loss: 0.3210 Epoch [175/1000], Loss: 0.3210 Epoch [176/1000], Loss: 0.3210 Epoch [177/1000], Loss: 0.3210 Epoch [178/1000], Loss: 0.3210 Epoch [179/1000], Loss: 0.3210 Epoch [180/1000], Loss: 0.3210 Epoch [181/1000], Loss: 0.3210 Epoch [182/1000], Loss: 0.3210 Epoch [183/1000], Loss: 0.3210 Epoch [184/1000], Loss: 0.3210 Epoch [185/1000], Loss: 0.3210 Epoch [186/1000], Loss: 0.3210 Epoch [187/1000], Loss: 0.3210 Epoch [188/1000], Loss: 0.3210 Epoch [189/1000], Loss: 0.3210 Epoch [190/1000], Loss: 0.3210 Epoch [191/1000], Loss: 0.3210 Epoch [192/1000], Loss: 0.3210 Epoch [193/1000], Loss: 0.3210 Epoch [194/1000], Loss: 0.3210 Epoch [195/1000], Loss: 0.3210 Epoch [196/1000], Loss: 0.3210 Epoch [197/1000], Loss: 0.3210 Epoch [198/1000], Loss: 0.3210 Epoch [199/1000], Loss: 0.3210 Epoch [200/1000], Loss: 0.3210 Epoch [201/1000], Loss: 0.3210 Epoch [202/1000], Loss: 0.3210 Epoch [203/1000], Loss: 0.3210 Epoch [204/1000], Loss: 0.3210 Epoch [205/1000], Loss: 0.3210 Epoch [206/1000], Loss: 0.3210 Epoch [207/1000], Loss: 0.3210 Epoch [208/1000], Loss: 0.3210 Epoch [209/1000], Loss: 0.3210 Epoch [210/1000], Loss: 0.3210 Epoch [211/1000], Loss: 0.3210 Epoch [212/1000], Loss: 0.3210 Epoch [213/1000], Loss: 0.3210 Epoch [214/1000], Loss: 0.3210 Epoch [215/1000], Loss: 0.3210 Epoch [216/1000], Loss: 0.3210 Epoch [217/1000], Loss: 0.3210 Epoch [218/1000], Loss: 0.3210 Epoch [219/1000], Loss: 0.3210 Epoch [220/1000], Loss: 0.3210 Epoch [221/1000], Loss: 0.3210 Epoch [222/1000], Loss: 0.3210 Epoch [223/1000], Loss: 0.3210 Epoch [224/1000], Loss: 0.3210 Epoch [225/1000], Loss: 0.3210 Epoch [226/1000], Loss: 0.3210 Epoch [227/1000], Loss: 0.3210 Epoch [228/1000], Loss: 0.3210 Epoch [229/1000], Loss: 0.3210 Epoch [230/1000], Loss: 0.3210 Epoch [231/1000], Loss: 0.3210 Epoch [232/1000], Loss: 0.3210 Epoch [233/1000], Loss: 0.3210 Epoch [234/1000], Loss: 0.3210 Epoch [235/1000], Loss: 0.3210 Epoch [236/1000], Loss: 0.3210 Epoch [237/1000], Loss: 0.3210 Epoch [238/1000], Loss: 0.3210 Epoch [239/1000], Loss: 0.3210 Epoch [240/1000], Loss: 0.3210 Epoch [241/1000], Loss: 0.3210 Epoch [242/1000], Loss: 0.3210 Epoch [243/1000], Loss: 0.3210 Epoch [244/1000], Loss: 0.3210 Epoch [245/1000], Loss: 0.3210 Epoch [246/1000], Loss: 0.3210 Epoch [247/1000], Loss: 0.3210 Epoch [248/1000], Loss: 0.3210 Epoch [249/1000], Loss: 0.3210 Epoch [250/1000], Loss: 0.3210 Epoch [251/1000], Loss: 0.3210 Epoch [252/1000], Loss: 0.3210 Epoch [253/1000], Loss: 0.3210 Epoch [254/1000], Loss: 0.3210 Epoch [255/1000], Loss: 0.3210 Epoch [256/1000], Loss: 0.3210 Epoch [257/1000], Loss: 0.3210 Epoch [258/1000], Loss: 0.3210 Epoch [259/1000], Loss: 0.3210 Epoch [260/1000], Loss: 0.3210 Epoch [261/1000], Loss: 0.3210 Epoch [262/1000], Loss: 0.3210 Epoch [263/1000], Loss: 0.3210 Epoch [264/1000], Loss: 0.3210 Epoch [265/1000], Loss: 0.3210 Epoch [266/1000], Loss: 0.3210 Epoch [267/1000], Loss: 0.3210 Epoch [268/1000], Loss: 0.3210 Epoch [269/1000], Loss: 0.3210 Epoch [270/1000], Loss: 0.3210 Epoch [271/1000], Loss: 0.3210 Epoch [272/1000], Loss: 0.3210 Epoch [273/1000], Loss: 0.3210 Epoch [274/1000], Loss: 0.3210 Epoch [275/1000], Loss: 0.3210 Epoch [276/1000], Loss: 0.3210 Epoch [277/1000], Loss: 0.3210 Epoch [278/1000], Loss: 0.3210 Epoch [279/1000], Loss: 0.3210 Epoch [280/1000], Loss: 0.3210 Epoch [281/1000], Loss: 0.3210 Epoch [282/1000], Loss: 0.3210 Epoch [283/1000], Loss: 0.3210 Epoch [284/1000], Loss: 0.3210 Epoch [285/1000], Loss: 0.3210 Epoch [286/1000], Loss: 0.3210 Epoch [287/1000], Loss: 0.3210 Epoch [288/1000], Loss: 0.3210 Epoch [289/1000], Loss: 0.3210 Epoch [290/1000], Loss: 0.3210 Epoch [291/1000], Loss: 0.3210 Epoch [292/1000], Loss: 0.3210 Epoch [293/1000], Loss: 0.3210 Epoch [294/1000], Loss: 0.3210 Epoch [295/1000], Loss: 0.3210 Epoch [296/1000], Loss: 0.3210 Epoch [297/1000], Loss: 0.3210 Epoch [298/1000], Loss: 0.3210 Epoch [299/1000], Loss: 0.3210 Epoch [300/1000], Loss: 0.3210 Epoch [301/1000], Loss: 0.3210 Epoch [302/1000], Loss: 0.3210 Epoch [303/1000], Loss: 0.3210 Epoch [304/1000], Loss: 0.3211 Epoch [305/1000], Loss: 0.3211 Epoch [306/1000], Loss: 0.3211 Epoch [307/1000], Loss: 0.3211 Epoch [308/1000], Loss: 0.3210 Epoch [309/1000], Loss: 0.3210 Epoch [310/1000], Loss: 0.3210 Epoch [311/1000], Loss: 0.3210 Epoch [312/1000], Loss: 0.3210 Epoch [313/1000], Loss: 0.3210 Epoch [314/1000], Loss: 0.3210 Epoch [315/1000], Loss: 0.3211 Epoch [316/1000], Loss: 0.3211 Epoch [317/1000], Loss: 0.3211 Epoch [318/1000], Loss: 0.3210 Epoch [319/1000], Loss: 0.3210 Epoch [320/1000], Loss: 0.3210 Epoch [321/1000], Loss: 0.3210 Epoch [322/1000], Loss: 0.3210 Epoch [323/1000], Loss: 0.3210 Epoch [324/1000], Loss: 0.3210 Epoch [325/1000], Loss: 0.3210 Epoch [326/1000], Loss: 0.3210 Epoch [327/1000], Loss: 0.3210 Epoch [328/1000], Loss: 0.3210 Epoch [329/1000], Loss: 0.3210 Epoch [330/1000], Loss: 0.3210 Epoch [331/1000], Loss: 0.3210 Epoch [332/1000], Loss: 0.3210 Epoch [333/1000], Loss: 0.3210 Epoch [334/1000], Loss: 0.3210 Epoch [335/1000], Loss: 0.3210 Epoch [336/1000], Loss: 0.3210 Epoch [337/1000], Loss: 0.3210 Epoch [338/1000], Loss: 0.3210 Epoch [339/1000], Loss: 0.3210 Epoch [340/1000], Loss: 0.3210 Epoch [341/1000], Loss: 0.3210 Epoch [342/1000], Loss: 0.3210 Epoch [343/1000], Loss: 0.3210 Epoch [344/1000], Loss: 0.3210 Epoch [345/1000], Loss: 0.3210 Epoch [346/1000], Loss: 0.3210 Epoch [347/1000], Loss: 0.3210 Epoch [348/1000], Loss: 0.3210 Epoch [349/1000], Loss: 0.3210 Epoch [350/1000], Loss: 0.3210 Epoch [351/1000], Loss: 0.3210 Epoch [352/1000], Loss: 0.3210 Epoch [353/1000], Loss: 0.3210 Epoch [354/1000], Loss: 0.3210 Epoch [355/1000], Loss: 0.3210 Epoch [356/1000], Loss: 0.3210 Epoch [357/1000], Loss: 0.3210 Epoch [358/1000], Loss: 0.3210 Epoch [359/1000], Loss: 0.3210 Epoch [360/1000], Loss: 0.3210 Epoch [361/1000], Loss: 0.3210 Epoch [362/1000], Loss: 0.3210 Epoch [363/1000], Loss: 0.3210 Epoch [364/1000], Loss: 0.3210 Epoch [365/1000], Loss: 0.3210 Epoch [366/1000], Loss: 0.3210 Epoch [367/1000], Loss: 0.3210 Epoch [368/1000], Loss: 0.3210 Epoch [369/1000], Loss: 0.3210 Epoch [370/1000], Loss: 0.3210 Epoch [371/1000], Loss: 0.3210 Epoch [372/1000], Loss: 0.3210 Epoch [373/1000], Loss: 0.3210 Epoch [374/1000], Loss: 0.3210 Epoch [375/1000], Loss: 0.3210 Epoch [376/1000], Loss: 0.3210 Epoch [377/1000], Loss: 0.3210 Epoch [378/1000], Loss: 0.3210 Epoch [379/1000], Loss: 0.3210 Epoch [380/1000], Loss: 0.3210 Epoch [381/1000], Loss: 0.3210 Epoch [382/1000], Loss: 0.3210 Epoch [383/1000], Loss: 0.3210 Epoch [384/1000], Loss: 0.3210 Epoch [385/1000], Loss: 0.3210 Epoch [386/1000], Loss: 0.3210 Epoch [387/1000], Loss: 0.3210 Epoch [388/1000], Loss: 0.3210 Epoch [389/1000], Loss: 0.3210 Epoch [390/1000], Loss: 0.3210 Epoch [391/1000], Loss: 0.3210 Epoch [392/1000], Loss: 0.3210 Epoch [393/1000], Loss: 0.3210 Epoch [394/1000], Loss: 0.3210 Epoch [395/1000], Loss: 0.3210 Epoch [396/1000], Loss: 0.3210 Epoch [397/1000], Loss: 0.3210 Epoch [398/1000], Loss: 0.3210 Epoch [399/1000], Loss: 0.3210 Epoch [400/1000], Loss: 0.3210 Epoch [401/1000], Loss: 0.3210 Epoch [402/1000], Loss: 0.3210 Epoch [403/1000], Loss: 0.3210 Epoch [404/1000], Loss: 0.3210 Epoch [405/1000], Loss: 0.3210 Epoch [406/1000], Loss: 0.3210 Epoch [407/1000], Loss: 0.3210 Epoch [408/1000], Loss: 0.3210 Epoch [409/1000], Loss: 0.3210 Epoch [410/1000], Loss: 0.3210 Epoch [411/1000], Loss: 0.3210 Epoch [412/1000], Loss: 0.3210 Epoch [413/1000], Loss: 0.3210 Epoch [414/1000], Loss: 0.3210 Epoch [415/1000], Loss: 0.3210 Epoch [416/1000], Loss: 0.3210 Epoch [417/1000], Loss: 0.3210 Epoch [418/1000], Loss: 0.3210 Epoch [419/1000], Loss: 0.3210 Epoch [420/1000], Loss: 0.3210 Epoch [421/1000], Loss: 0.3210 Epoch [422/1000], Loss: 0.3210 Epoch [423/1000], Loss: 0.3210 Epoch [424/1000], Loss: 0.3210 Epoch [425/1000], Loss: 0.3210 Epoch [426/1000], Loss: 0.3210 Epoch [427/1000], Loss: 0.3210 Epoch [428/1000], Loss: 0.3210 Epoch [429/1000], Loss: 0.3211 Epoch [430/1000], Loss: 0.3211 Epoch [431/1000], Loss: 0.3211 Epoch [432/1000], Loss: 0.3211 Epoch [433/1000], Loss: 0.3211 Epoch [434/1000], Loss: 0.3211 Epoch [435/1000], Loss: 0.3211 Epoch [436/1000], Loss: 0.3211 Epoch [437/1000], Loss: 0.3211 Epoch [438/1000], Loss: 0.3210 Epoch [439/1000], Loss: 0.3210 Epoch [440/1000], Loss: 0.3210 Epoch [441/1000], Loss: 0.3210 Epoch [442/1000], Loss: 0.3210 Epoch [443/1000], Loss: 0.3210 Epoch [444/1000], Loss: 0.3210 Epoch [445/1000], Loss: 0.3210 Epoch [446/1000], Loss: 0.3210 Epoch [447/1000], Loss: 0.3210 Epoch [448/1000], Loss: 0.3210 Epoch [449/1000], Loss: 0.3211 Epoch [450/1000], Loss: 0.3210 Epoch [451/1000], Loss: 0.3210 Epoch [452/1000], Loss: 0.3210 Epoch [453/1000], Loss: 0.3210 Epoch [454/1000], Loss: 0.3210 Epoch [455/1000], Loss: 0.3210 Epoch [456/1000], Loss: 0.3211 Epoch [457/1000], Loss: 0.3210 Epoch [458/1000], Loss: 0.3210 Epoch [459/1000], Loss: 0.3210 Epoch [460/1000], Loss: 0.3210 Epoch [461/1000], Loss: 0.3210 Epoch [462/1000], Loss: 0.3210 Epoch [463/1000], Loss: 0.3210 Epoch [464/1000], Loss: 0.3210 Epoch [465/1000], Loss: 0.3210 Epoch [466/1000], Loss: 0.3210 Epoch [467/1000], Loss: 0.3210 Epoch [468/1000], Loss: 0.3210 Epoch [469/1000], Loss: 0.3210 Epoch [470/1000], Loss: 0.3210 Epoch [471/1000], Loss: 0.3210 Epoch [472/1000], Loss: 0.3210 Epoch [473/1000], Loss: 0.3210 Epoch [474/1000], Loss: 0.3210 Epoch [475/1000], Loss: 0.3210 Epoch [476/1000], Loss: 0.3210 Epoch [477/1000], Loss: 0.3210 Epoch [478/1000], Loss: 0.3210 Epoch [479/1000], Loss: 0.3210 Epoch [480/1000], Loss: 0.3210 Epoch [481/1000], Loss: 0.3210 Epoch [482/1000], Loss: 0.3210 Epoch [483/1000], Loss: 0.3210 Epoch [484/1000], Loss: 0.3210 Epoch [485/1000], Loss: 0.3210 Epoch [486/1000], Loss: 0.3210 Epoch [487/1000], Loss: 0.3210 Epoch [488/1000], Loss: 0.3210 Epoch [489/1000], Loss: 0.3210 Epoch [490/1000], Loss: 0.3210 Epoch [491/1000], Loss: 0.3210 Epoch [492/1000], Loss: 0.3210 Epoch [493/1000], Loss: 0.3209 Epoch [494/1000], Loss: 0.3209 Epoch [495/1000], Loss: 0.3209 Epoch [496/1000], Loss: 0.3209 Epoch [497/1000], Loss: 0.3208 Epoch [498/1000], Loss: 0.3209 Epoch [499/1000], Loss: 0.3209 Epoch [500/1000], Loss: 0.3209 Epoch [501/1000], Loss: 0.3209 Epoch [502/1000], Loss: 0.3209 Epoch [503/1000], Loss: 0.3208 Epoch [504/1000], Loss: 0.3209 Epoch [505/1000], Loss: 0.3208 Epoch [506/1000], Loss: 0.3208 Epoch [507/1000], Loss: 0.3209 Epoch [508/1000], Loss: 0.3209 Epoch [509/1000], Loss: 0.3209 Epoch [510/1000], Loss: 0.3209 Epoch [511/1000], Loss: 0.3209 Epoch [512/1000], Loss: 0.3209 Epoch [513/1000], Loss: 0.3209 Epoch [514/1000], Loss: 0.3209 Epoch [515/1000], Loss: 0.3209 Epoch [516/1000], Loss: 0.3209 Epoch [517/1000], Loss: 0.3209 Epoch [518/1000], Loss: 0.3209 Epoch [519/1000], Loss: 0.3209 Epoch [520/1000], Loss: 0.3209 Epoch [521/1000], Loss: 0.3209 Epoch [522/1000], Loss: 0.3209 Epoch [523/1000], Loss: 0.3209 Epoch [524/1000], Loss: 0.3208 Epoch [525/1000], Loss: 0.3208 Epoch [526/1000], Loss: 0.3209 Epoch [527/1000], Loss: 0.3208 Epoch [528/1000], Loss: 0.3208 Epoch [529/1000], Loss: 0.3208 Epoch [530/1000], Loss: 0.3208 Epoch [531/1000], Loss: 0.3209 Epoch [532/1000], Loss: 0.3209 Epoch [533/1000], Loss: 0.3209 Epoch [534/1000], Loss: 0.3209 Epoch [535/1000], Loss: 0.3209 Epoch [536/1000], Loss: 0.3209 Epoch [537/1000], Loss: 0.3208 Epoch [538/1000], Loss: 0.3208 Epoch [539/1000], Loss: 0.3208 Epoch [540/1000], Loss: 0.3208 Epoch [541/1000], Loss: 0.3208 Epoch [542/1000], Loss: 0.3208 Epoch [543/1000], Loss: 0.3208 Epoch [544/1000], Loss: 0.3208 Epoch [545/1000], Loss: 0.3208 Epoch [546/1000], Loss: 0.3208 Epoch [547/1000], Loss: 0.3208 Epoch [548/1000], Loss: 0.3208 Epoch [549/1000], Loss: 0.3208 Epoch [550/1000], Loss: 0.3208 Epoch [551/1000], Loss: 0.3208 Epoch [552/1000], Loss: 0.3208 Epoch [553/1000], Loss: 0.3208 Epoch [554/1000], Loss: 0.3208 Epoch [555/1000], Loss: 0.3208 Epoch [556/1000], Loss: 0.3208 Epoch [557/1000], Loss: 0.3208 Epoch [558/1000], Loss: 0.3208 Epoch [559/1000], Loss: 0.3208 Epoch [560/1000], Loss: 0.3208 Epoch [561/1000], Loss: 0.3208 Epoch [562/1000], Loss: 0.3208 Epoch [563/1000], Loss: 0.3208 Epoch [564/1000], Loss: 0.3208 Epoch [565/1000], Loss: 0.3208 Epoch [566/1000], Loss: 0.3208 Epoch [567/1000], Loss: 0.3207 Epoch [568/1000], Loss: 0.3207 Epoch [569/1000], Loss: 0.3207 Epoch [570/1000], Loss: 0.3207 Epoch [571/1000], Loss: 0.3207 Epoch [572/1000], Loss: 0.3207 Epoch [573/1000], Loss: 0.3207 Epoch [574/1000], Loss: 0.3207 Epoch [575/1000], Loss: 0.3207 Epoch [576/1000], Loss: 0.3207 Epoch [577/1000], Loss: 0.3207 Epoch [578/1000], Loss: 0.3207 Epoch [579/1000], Loss: 0.3207 Epoch [580/1000], Loss: 0.3207 Epoch [581/1000], Loss: 0.3207 Epoch [582/1000], Loss: 0.3207 Epoch [583/1000], Loss: 0.3207 Epoch [584/1000], Loss: 0.3207 Epoch [585/1000], Loss: 0.3207 Epoch [586/1000], Loss: 0.3206 Epoch [587/1000], Loss: 0.3207 Epoch [588/1000], Loss: 0.3206 Epoch [589/1000], Loss: 0.3207 Epoch [590/1000], Loss: 0.3207 Epoch [591/1000], Loss: 0.3207 Epoch [592/1000], Loss: 0.3207 Epoch [593/1000], Loss: 0.3207 Epoch [594/1000], Loss: 0.3207 Epoch [595/1000], Loss: 0.3207 Epoch [596/1000], Loss: 0.3207 Epoch [597/1000], Loss: 0.3206 Epoch [598/1000], Loss: 0.3207 Epoch [599/1000], Loss: 0.3206 Epoch [600/1000], Loss: 0.3206 Epoch [601/1000], Loss: 0.3206 Epoch [602/1000], Loss: 0.3206 Epoch [603/1000], Loss: 0.3206 Epoch [604/1000], Loss: 0.3206 Epoch [605/1000], Loss: 0.3206 Epoch [606/1000], Loss: 0.3206 Epoch [607/1000], Loss: 0.3206 Epoch [608/1000], Loss: 0.3206 Epoch [609/1000], Loss: 0.3206 Epoch [610/1000], Loss: 0.3206 Epoch [611/1000], Loss: 0.3206 Epoch [612/1000], Loss: 0.3206 Epoch [613/1000], Loss: 0.3206 Epoch [614/1000], Loss: 0.3206 Epoch [615/1000], Loss: 0.3206 Epoch [616/1000], Loss: 0.3206 Epoch [617/1000], Loss: 0.3205 Epoch [618/1000], Loss: 0.3205 Epoch [619/1000], Loss: 0.3205 Epoch [620/1000], Loss: 0.3205 Epoch [621/1000], Loss: 0.3205 Epoch [622/1000], Loss: 0.3205 Epoch [623/1000], Loss: 0.3205 Epoch [624/1000], Loss: 0.3205 Epoch [625/1000], Loss: 0.3205 Epoch [626/1000], Loss: 0.3205 Epoch [627/1000], Loss: 0.3205 Epoch [628/1000], Loss: 0.3205 Epoch [629/1000], Loss: 0.3205 Epoch [630/1000], Loss: 0.3205 Epoch [631/1000], Loss: 0.3205 Epoch [632/1000], Loss: 0.3205 Epoch [633/1000], Loss: 0.3205 Epoch [634/1000], Loss: 0.3205 Epoch [635/1000], Loss: 0.3205 Epoch [636/1000], Loss: 0.3205 Epoch [637/1000], Loss: 0.3205 Epoch [638/1000], Loss: 0.3205 Epoch [639/1000], Loss: 0.3205 Epoch [640/1000], Loss: 0.3205 Epoch [641/1000], Loss: 0.3205 Epoch [642/1000], Loss: 0.3205 Epoch [643/1000], Loss: 0.3205 Epoch [644/1000], Loss: 0.3205 Epoch [645/1000], Loss: 0.3205 Epoch [646/1000], Loss: 0.3205 Epoch [647/1000], Loss: 0.3205 Epoch [648/1000], Loss: 0.3204 Epoch [649/1000], Loss: 0.3205 Epoch [650/1000], Loss: 0.3205 Epoch [651/1000], Loss: 0.3205 Epoch [652/1000], Loss: 0.3204 Epoch [653/1000], Loss: 0.3204 Epoch [654/1000], Loss: 0.3205 Epoch [655/1000], Loss: 0.3204 Epoch [656/1000], Loss: 0.3205 Epoch [657/1000], Loss: 0.3205 Epoch [658/1000], Loss: 0.3205 Epoch [659/1000], Loss: 0.3205 Epoch [660/1000], Loss: 0.3204 Epoch [661/1000], Loss: 0.3204 Epoch [662/1000], Loss: 0.3204 Epoch [663/1000], Loss: 0.3205 Epoch [664/1000], Loss: 0.3204 Epoch [665/1000], Loss: 0.3204 Epoch [666/1000], Loss: 0.3204 Epoch [667/1000], Loss: 0.3204 Epoch [668/1000], Loss: 0.3205 Epoch [669/1000], Loss: 0.3204 Epoch [670/1000], Loss: 0.3205 Epoch [671/1000], Loss: 0.3205 Epoch [672/1000], Loss: 0.3204 Epoch [673/1000], Loss: 0.3204 Epoch [674/1000], Loss: 0.3205 Epoch [675/1000], Loss: 0.3204 Epoch [676/1000], Loss: 0.3204 Epoch [677/1000], Loss: 0.3204 Epoch [678/1000], Loss: 0.3204 Epoch [679/1000], Loss: 0.3204 Epoch [680/1000], Loss: 0.3204 Epoch [681/1000], Loss: 0.3204 Epoch [682/1000], Loss: 0.3204 Epoch [683/1000], Loss: 0.3204 Epoch [684/1000], Loss: 0.3204 Epoch [685/1000], Loss: 0.3204 Epoch [686/1000], Loss: 0.3204 Epoch [687/1000], Loss: 0.3204 Epoch [688/1000], Loss: 0.3204 Epoch [689/1000], Loss: 0.3204 Epoch [690/1000], Loss: 0.3204 Epoch [691/1000], Loss: 0.3204 Epoch [692/1000], Loss: 0.3204 Epoch [693/1000], Loss: 0.3204 Epoch [694/1000], Loss: 0.3204 Epoch [695/1000], Loss: 0.3204 Epoch [696/1000], Loss: 0.3204 Epoch [697/1000], Loss: 0.3204 Epoch [698/1000], Loss: 0.3203 Epoch [699/1000], Loss: 0.3203 Epoch [700/1000], Loss: 0.3204 Epoch [701/1000], Loss: 0.3203 Epoch [702/1000], Loss: 0.3203 Epoch [703/1000], Loss: 0.3203 Epoch [704/1000], Loss: 0.3203 Epoch [705/1000], Loss: 0.3203 Epoch [706/1000], Loss: 0.3203 Epoch [707/1000], Loss: 0.3203 Epoch [708/1000], Loss: 0.3203 Epoch [709/1000], Loss: 0.3203 Epoch [710/1000], Loss: 0.3203 Epoch [711/1000], Loss: 0.3203 Epoch [712/1000], Loss: 0.3203 Epoch [713/1000], Loss: 0.3203 Epoch [714/1000], Loss: 0.3203 Epoch [715/1000], Loss: 0.3202 Epoch [716/1000], Loss: 0.3203 Epoch [717/1000], Loss: 0.3202 Epoch [718/1000], Loss: 0.3202 Epoch [719/1000], Loss: 0.3202 Epoch [720/1000], Loss: 0.3202 Epoch [721/1000], Loss: 0.3202 Epoch [722/1000], Loss: 0.3202 Epoch [723/1000], Loss: 0.3202 Epoch [724/1000], Loss: 0.3202 Epoch [725/1000], Loss: 0.3202 Epoch [726/1000], Loss: 0.3202 Epoch [727/1000], Loss: 0.3202 Epoch [728/1000], Loss: 0.3202 Epoch [729/1000], Loss: 0.3202 Epoch [730/1000], Loss: 0.3202 Epoch [731/1000], Loss: 0.3202 Epoch [732/1000], Loss: 0.3202 Epoch [733/1000], Loss: 0.3202 Epoch [734/1000], Loss: 0.3202 Epoch [735/1000], Loss: 0.3202 Epoch [736/1000], Loss: 0.3202 Epoch [737/1000], Loss: 0.3202 Epoch [738/1000], Loss: 0.3202 Epoch [739/1000], Loss: 0.3202 Epoch [740/1000], Loss: 0.3202 Epoch [741/1000], Loss: 0.3202 Epoch [742/1000], Loss: 0.3202 Epoch [743/1000], Loss: 0.3202 Epoch [744/1000], Loss: 0.3202 Epoch [745/1000], Loss: 0.3202 Epoch [746/1000], Loss: 0.3202 Epoch [747/1000], Loss: 0.3202 Epoch [748/1000], Loss: 0.3202 Epoch [749/1000], Loss: 0.3202 Epoch [750/1000], Loss: 0.3202 Epoch [751/1000], Loss: 0.3202 Epoch [752/1000], Loss: 0.3202 Epoch [753/1000], Loss: 0.3202 Epoch [754/1000], Loss: 0.3202 Epoch [755/1000], Loss: 0.3202 Epoch [756/1000], Loss: 0.3202 Epoch [757/1000], Loss: 0.3202 Epoch [758/1000], Loss: 0.3202 Epoch [759/1000], Loss: 0.3202 Epoch [760/1000], Loss: 0.3202 Epoch [761/1000], Loss: 0.3202 Epoch [762/1000], Loss: 0.3202 Epoch [763/1000], Loss: 0.3201 Epoch [764/1000], Loss: 0.3201 Epoch [765/1000], Loss: 0.3201 Epoch [766/1000], Loss: 0.3201 Epoch [767/1000], Loss: 0.3201 Epoch [768/1000], Loss: 0.3201 Epoch [769/1000], Loss: 0.3201 Epoch [770/1000], Loss: 0.3201 Epoch [771/1000], Loss: 0.3201 Epoch [772/1000], Loss: 0.3201 Epoch [773/1000], Loss: 0.3201 Epoch [774/1000], Loss: 0.3201 Epoch [775/1000], Loss: 0.3201 Epoch [776/1000], Loss: 0.3201 Epoch [777/1000], Loss: 0.3201 Epoch [778/1000], Loss: 0.3201 Epoch [779/1000], Loss: 0.3201 Epoch [780/1000], Loss: 0.3201 Epoch [781/1000], Loss: 0.3201 Epoch [782/1000], Loss: 0.3201 Epoch [783/1000], Loss: 0.3201 Epoch [784/1000], Loss: 0.3201 Epoch [785/1000], Loss: 0.3201 Epoch [786/1000], Loss: 0.3201 Epoch [787/1000], Loss: 0.3200 Epoch [788/1000], Loss: 0.3200 Epoch [789/1000], Loss: 0.3200 Epoch [790/1000], Loss: 0.3200 Epoch [791/1000], Loss: 0.3200 Epoch [792/1000], Loss: 0.3200 Epoch [793/1000], Loss: 0.3201 Epoch [794/1000], Loss: 0.3200 Epoch [795/1000], Loss: 0.3201 Epoch [796/1000], Loss: 0.3200 Epoch [797/1000], Loss: 0.3200 Epoch [798/1000], Loss: 0.3200 Epoch [799/1000], Loss: 0.3200 Epoch [800/1000], Loss: 0.3200 Epoch [801/1000], Loss: 0.3200 Epoch [802/1000], Loss: 0.3200 Epoch [803/1000], Loss: 0.3200 Epoch [804/1000], Loss: 0.3200 Epoch [805/1000], Loss: 0.3200 Epoch [806/1000], Loss: 0.3199 Epoch [807/1000], Loss: 0.3200 Epoch [808/1000], Loss: 0.3200 Epoch [809/1000], Loss: 0.3200 Epoch [810/1000], Loss: 0.3200 Epoch [811/1000], Loss: 0.3199 Epoch [812/1000], Loss: 0.3199 Epoch [813/1000], Loss: 0.3199 Epoch [814/1000], Loss: 0.3199 Epoch [815/1000], Loss: 0.3199 Epoch [816/1000], Loss: 0.3199 Epoch [817/1000], Loss: 0.3199 Epoch [818/1000], Loss: 0.3199 Epoch [819/1000], Loss: 0.3199 Epoch [820/1000], Loss: 0.3198 Epoch [821/1000], Loss: 0.3199 Epoch [822/1000], Loss: 0.3198 Epoch [823/1000], Loss: 0.3198 Epoch [824/1000], Loss: 0.3198 Epoch [825/1000], Loss: 0.3198 Epoch [826/1000], Loss: 0.3197 Epoch [827/1000], Loss: 0.3197 Epoch [828/1000], Loss: 0.3197 Epoch [829/1000], Loss: 0.3197 Epoch [830/1000], Loss: 0.3198 Epoch [831/1000], Loss: 0.3197 Epoch [832/1000], Loss: 0.3197 Epoch [833/1000], Loss: 0.3197 Epoch [834/1000], Loss: 0.3196 Epoch [835/1000], Loss: 0.3197 Epoch [836/1000], Loss: 0.3196 Epoch [837/1000], Loss: 0.3196 Epoch [838/1000], Loss: 0.3195 Epoch [839/1000], Loss: 0.3195 Epoch [840/1000], Loss: 0.3195 Epoch [841/1000], Loss: 0.3195 Epoch [842/1000], Loss: 0.3195 Epoch [843/1000], Loss: 0.3194 Epoch [844/1000], Loss: 0.3195 Epoch [845/1000], Loss: 0.3194 Epoch [846/1000], Loss: 0.3194 Epoch [847/1000], Loss: 0.3194 Epoch [848/1000], Loss: 0.3194 Epoch [849/1000], Loss: 0.3194 Epoch [850/1000], Loss: 0.3193 Epoch [851/1000], Loss: 0.3193 Epoch [852/1000], Loss: 0.3193 Epoch [853/1000], Loss: 0.3193 Epoch [854/1000], Loss: 0.3192 Epoch [855/1000], Loss: 0.3192 Epoch [856/1000], Loss: 0.3192 Epoch [857/1000], Loss: 0.3192 Epoch [858/1000], Loss: 0.3192 Epoch [859/1000], Loss: 0.3192 Epoch [860/1000], Loss: 0.3192 Epoch [861/1000], Loss: 0.3192 Epoch [862/1000], Loss: 0.3191 Epoch [863/1000], Loss: 0.3191 Epoch [864/1000], Loss: 0.3191 Epoch [865/1000], Loss: 0.3191 Epoch [866/1000], Loss: 0.3190 Epoch [867/1000], Loss: 0.3190 Epoch [868/1000], Loss: 0.3190 Epoch [869/1000], Loss: 0.3190 Epoch [870/1000], Loss: 0.3190 Epoch [871/1000], Loss: 0.3190 Epoch [872/1000], Loss: 0.3189 Epoch [873/1000], Loss: 0.3189 Epoch [874/1000], Loss: 0.3189 Epoch [875/1000], Loss: 0.3189 Epoch [876/1000], Loss: 0.3188 Epoch [877/1000], Loss: 0.3188 Epoch [878/1000], Loss: 0.3188 Epoch [879/1000], Loss: 0.3188 Epoch [880/1000], Loss: 0.3188 Epoch [881/1000], Loss: 0.3187 Epoch [882/1000], Loss: 0.3188 Epoch [883/1000], Loss: 0.3187 Epoch [884/1000], Loss: 0.3187 Epoch [885/1000], Loss: 0.3187 Epoch [886/1000], Loss: 0.3187 Epoch [887/1000], Loss: 0.3186 Epoch [888/1000], Loss: 0.3186 Epoch [889/1000], Loss: 0.3186 Epoch [890/1000], Loss: 0.3186 Epoch [891/1000], Loss: 0.3186 Epoch [892/1000], Loss: 0.3186 Epoch [893/1000], Loss: 0.3186 Epoch [894/1000], Loss: 0.3186 Epoch [895/1000], Loss: 0.3185 Epoch [896/1000], Loss: 0.3185 Epoch [897/1000], Loss: 0.3185 Epoch [898/1000], Loss: 0.3185 Epoch [899/1000], Loss: 0.3185 Epoch [900/1000], Loss: 0.3185 Epoch [901/1000], Loss: 0.3185 Epoch [902/1000], Loss: 0.3184 Epoch [903/1000], Loss: 0.3184 Epoch [904/1000], Loss: 0.3184 Epoch [905/1000], Loss: 0.3184 Epoch [906/1000], Loss: 0.3184 Epoch [907/1000], Loss: 0.3184 Epoch [908/1000], Loss: 0.3184 Epoch [909/1000], Loss: 0.3183 Epoch [910/1000], Loss: 0.3183 Epoch [911/1000], Loss: 0.3183 Epoch [912/1000], Loss: 0.3184 Epoch [913/1000], Loss: 0.3183 Epoch [914/1000], Loss: 0.3183 Epoch [915/1000], Loss: 0.3183 Epoch [916/1000], Loss: 0.3183 Epoch [917/1000], Loss: 0.3183 Epoch [918/1000], Loss: 0.3183 Epoch [919/1000], Loss: 0.3182 Epoch [920/1000], Loss: 0.3182 Epoch [921/1000], Loss: 0.3182 Epoch [922/1000], Loss: 0.3182 Epoch [923/1000], Loss: 0.3182 Epoch [924/1000], Loss: 0.3182 Epoch [925/1000], Loss: 0.3182 Epoch [926/1000], Loss: 0.3182 Epoch [927/1000], Loss: 0.3182 Epoch [928/1000], Loss: 0.3182 Epoch [929/1000], Loss: 0.3182 Epoch [930/1000], Loss: 0.3182 Epoch [931/1000], Loss: 0.3182 Epoch [932/1000], Loss: 0.3182 Epoch [933/1000], Loss: 0.3182 Epoch [934/1000], Loss: 0.3181 Epoch [935/1000], Loss: 0.3182 Epoch [936/1000], Loss: 0.3181 Epoch [937/1000], Loss: 0.3181 Epoch [938/1000], Loss: 0.3181 Epoch [939/1000], Loss: 0.3181 Epoch [940/1000], Loss: 0.3182 Epoch [941/1000], Loss: 0.3181 Epoch [942/1000], Loss: 0.3181 Epoch [943/1000], Loss: 0.3181 Epoch [944/1000], Loss: 0.3181 Epoch [945/1000], Loss: 0.3181 Epoch [946/1000], Loss: 0.3181 Epoch [947/1000], Loss: 0.3181 Epoch [948/1000], Loss: 0.3181 Epoch [949/1000], Loss: 0.3181 Epoch [950/1000], Loss: 0.3181 Epoch [951/1000], Loss: 0.3180 Epoch [952/1000], Loss: 0.3180 Epoch [953/1000], Loss: 0.3180 Epoch [954/1000], Loss: 0.3180 Epoch [955/1000], Loss: 0.3180 Epoch [956/1000], Loss: 0.3180 Epoch [957/1000], Loss: 0.3180 Epoch [958/1000], Loss: 0.3180 Epoch [959/1000], Loss: 0.3180 Epoch [960/1000], Loss: 0.3180 Epoch [961/1000], Loss: 0.3180 Epoch [962/1000], Loss: 0.3180 Epoch [963/1000], Loss: 0.3180 Epoch [964/1000], Loss: 0.3181 Epoch [965/1000], Loss: 0.3181 Epoch [966/1000], Loss: 0.3180 Epoch [967/1000], Loss: 0.3180 Epoch [968/1000], Loss: 0.3180 Epoch [969/1000], Loss: 0.3180 Epoch [970/1000], Loss: 0.3180 Epoch [971/1000], Loss: 0.3180 Epoch [972/1000], Loss: 0.3180 Epoch [973/1000], Loss: 0.3180 Epoch [974/1000], Loss: 0.3180 Epoch [975/1000], Loss: 0.3180 Epoch [976/1000], Loss: 0.3180 Epoch [977/1000], Loss: 0.3180 Epoch [978/1000], Loss: 0.3180 Epoch [979/1000], Loss: 0.3180 Epoch [980/1000], Loss: 0.3180 Epoch [981/1000], Loss: 0.3179 Epoch [982/1000], Loss: 0.3179 Epoch [983/1000], Loss: 0.3179 Epoch [984/1000], Loss: 0.3179 Epoch [985/1000], Loss: 0.3179 Epoch [986/1000], Loss: 0.3179 Epoch [987/1000], Loss: 0.3179 Epoch [988/1000], Loss: 0.3179 Epoch [989/1000], Loss: 0.3179 Epoch [990/1000], Loss: 0.3179 Epoch [991/1000], Loss: 0.3179 Epoch [992/1000], Loss: 0.3179 Epoch [993/1000], Loss: 0.3179 Epoch [994/1000], Loss: 0.3179 Epoch [995/1000], Loss: 0.3179 Epoch [996/1000], Loss: 0.3178 Epoch [997/1000], Loss: 0.3178 Epoch [998/1000], Loss: 0.3178 Epoch [999/1000], Loss: 0.3178 Epoch [1000/1000], Loss: 0.3178
class PointModel(nn.Module):
def __init__(self, n, use_cuda=True):
super(PointModel, self).__init__()
self.num = n
self.use_cuda = use_cuda
self.posx = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
self.posy = torch.nn.Parameter(
torch.rand((self.num), requires_grad=True))
def forward(self, isize):
posx = self.posx
posy = self.posy
X = torch.unsqueeze(torch.arange(
0.5, isize + 0.5, 1) / isize, 0)
Y = torch.unsqueeze(torch.arange(
0.5, isize + 0.5, 1) / isize, 0)
I = torch.unsqueeze(torch.ones(isize), 0)
if self.use_cuda:
X = X.cuda()
Y = Y.cuda()
I = I.cuda()
X = X * I
Y = torch.transpose(Y * I, 0, 1)
X = X.unsqueeze_(0)
Y = Y.unsqueeze_(0)
X = X.expand(self.num, 1, isize, isize) - \
posx.reshape(self.num, 1, 1, 1)
Y = Y.expand(self.num, 1, isize, isize) - \
posy.reshape(self.num, 1, 1, 1)
R = torch.sqrt(X.square() + Y.square())
sharpness = float(1 << 9)
ir = 0.5 / float(isize)
filters = torch.exp(-R / ir)
return (filters)
num = 1 << 12
model = PointModel(num, use_cuda=True)
model = model.cuda()
optimizer = optim.AdamW(model.parameters(), lr=0.005)
out = None
try:
shutil.rmtree('.scratch')
except:
pass
os.mkdir('.scratch')
def brightness(val):
return torch.sqrt(0.241*(val[0]**2) + 0.691*(val[1]**2) + 0.068*(val[2]**2))
for epoch in range(0, num_epochs):
with torch.amp.autocast(device_type="cuda", dtype=torch.float16):
torch.cuda.empty_cache()
filters = model(isize)
bg = torch.tensor([1.0]).expand(3, isize, isize).cuda() * torch.exp(-4. * (torch.sum(filters.expand(num, 1, isize, isize), (0))))
out = bg.cuda()
pic_loss = (((( (img-out) ).square()))).mean().sqrt()
loss = pic_loss
optimizer.zero_grad()
loss.backward()
optimizer.step()
im = out.clamp(0.0, 1.0).detach().permute(1,2,0).cpu().numpy()
plt.imsave(".scratch/out_" + str(epoch) + ".png", im)
print(f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}')
torch.save(model.state_dict(), 'model.ckpt')
plt.imsave("experiment_" + str(experiment_number) + ".png", im)
target_size = 256
from moviepy.editor import *
import cv2
fourcc = cv2.VideoWriter_fourcc(*"H264")
video = cv2.VideoWriter("experiment_video_" + str(experiment_number) + ".mp4", fourcc, 24, (target_size, target_size))
gen = {}
for n in range(0, num_epochs):
try:
image = cv2.imread(f".scratch/out_" + str(n) + ".png")
h = image.shape[0]
w = image.shape[1]
# for y in range(0, h):
# for x in range(0, w):
# image[x][y][0] = 1.0 - image[x][y][0]
image = cv2.resize(image, (target_size,target_size), interpolation=cv2.INTER_LANCZOS4)
video.write(image)
# print(f"Finished{n}")
except:
break
video.release()
torch.save(model.state_dict(), 'model.ckpt')
isize = 256
num = 1024
white = torch.tensor([1.0]).expand(num, 3, isize, isize)
model = EllipseModel(n=num, use_cuda=False)
model.load_state_dict(torch.load('model.ckpt'))
model = model.cpu()
filters_soft, filters2, radius, colors = model(isize, 0.001)
# mrgb = torch.sum(white*filters2*(filters_soft > 0.0), (2, 3),
# keepdim=True)/(torch.sum(filters2*(filters_soft > 0.0), (2, 3), keepdim=True)+0.00001)
rgb = colors.reshape((num, 3, 1, 1))*filters2.expand(num, 3, isize, isize)
out = torch.sum(filters2*rgb, 0)
out = out.clamp(0.0, 1.0)
plt.imsave("experiment.png", out.permute(1, 2, 0).detach().cpu().numpy())
from IPython.display import Video
Video("video.mp4")
class Model