====>> Wed Mar 16 12:16:26 2022 Pass time: 0:02:06.581927
==>> save samples 13!
barbara
Load Data: barbara
====>> Build Net
====>> Load I model
====>> Train
torch.Size([1, 3, 544, 704]) torch.Size([1, 3, 544, 704])
Traceback (most recent call last):
File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 410, in <module>
File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 301, in train
lc_time = time.asctime(time.localtime(time.time()))
File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 97, in loss_func
u11 = (f1 - dive1 + b2).to(torch.float32)
RuntimeError: The size of tensor a (704) must match the size of tensor b (320) at non-singleton dimension 3
Process finished with exit code 1
应该是图像维度不对,发现问题:原来定义的这个代码固定了图像维度
q1 = torch.zeros([1, 3, 320, 320])
于是改为输入图像的维度,成功
q1 = torch.zeros(f.shape)
q1 = q1.to(device)
b1 = b2 = q2 = q1
已经开始运行啦,进入调参数过程
不知道为什么,当我增加batch_size=5后(原来是1),就报错
====>> Train
Traceback (most recent call last):
File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 395, in <module>
train(opt)
File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 295, in train
print(outstr + ' Loss = %f' % loss.data.cpu().numpy())
UnboundLocalError: local variable 'loss' referenced before assignment
Process finished with exit code 1
分析局部变量与全局变量,在循环外加入这行语句
loss = None
但是报错了
====>> Train
Traceback (most recent call last):
File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 395, in <module>
train(opt)
File "C:/Users/shang/Desktop/STDN_LI/TVGnet/OSV_q.py", line 295, in train
print(outstr + ' Loss = %f' % loss.data.cpu().numpy())
AttributeError: 'NoneType' object has no attribute 'data'
Process finished with exit code 1
也不行,先不改batch_size吧,先调别的参数试试