2020-11-23

本文记录了在调试深度学习代码时遇到的TypeError问题,具体涉及upsample_bilinear2d函数的output_size参数类型错误。作者通过排除法和debug定位到问题在于批处理大小(batch size)的设置,当batch size不为1时,输出尺寸会被保存为Tensor而非所需的整数元组。解决方案是确保测试时batch size设为1。
摘要由CSDN通过智能技术生成

TypeError: upsample_bilinear2d(): argument ‘output_size’ must be tuple of ints, but found element of type Tensor at pos 1

调试代码遇到的大坑,报错如下:
在这里插入图片描述

D:\anconda\envs\python37\python.exe D:/document/memo/LDF-1117/train-coarse/test.py

Parameters...
datapath  : D:/date set/saliency_test/ECSSD
snapshot  : ./out/model-37
mode      : test
D:\anconda\envs\python37\lib\site-packages\torch\nn\functional.py:2506: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
  "See the documentation of nn.Upsample for details.".format(mode)
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值