RuntimeError: The size of tensor a (96) must match the size of tensor b (95) at non-singleton dimens

复现PSMNet时候出现的bug。

出错在output = model(imgL,imgR)

一开始以为左右两图维度不一致。换成output = model(imgR,imgR)之后依旧报错

翻墙查阅pytorch资料


If two tensors xy are “broadcastable”, the resulting tensor size is calculated as follows:

  • If the number of dimensions of x and y are not equal, prepend 1 to the dimensions of the tensor with fewer dimensions to make them equal length.
  • Then, for each dimension size, the resulting dimension size is the max of the sizes of x and yalong that dimension.
也就是说维度不一样~

再细看报错log:

Traceback (most recent call last):
  File "submission.py", line 122, in <module>
    main()
  File "submission.py", line 113, in main
    pred_disp = test(imgL,imgR)
  File "submission.py", line 84, in test
    output = model(imgR,imgR)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/parallel/data_parallel.py", line 71, in forward
    return self.module(*inputs[0], **kwargs[0])
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lvhao/PSMNet-master/models/stackhourglass.py", line 124, in forward
    out1, pre1, post1 = self.dres2(cost0, None, None) 
  File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 357, in __call__
    result = self.forward(*input, **kwargs)
  File "/home/lvhao/PSMNet-master/models/stackhourglass.py", line 46, in forward
    post = F.relu(self.conv5(out)+pre, inplace=True) 

还是维度问题~


  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 18
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 18
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值