OSV_q The size of tensor a (704) must match the size of tensor b (320) at non-singleton dime

====>> 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

http://t.csdn.cn/VwT8M

分析局部变量与全局变量,在循环外加入这行语句

 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

http://t.csdn.cn/EwpTS

也不行,先不改batch_size吧,先调别的参数试试

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值