赞
踩
自己在使用pytorch遇到的各种问题及解决方案:
RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #4 'mat1'
RuntimeError: The size of tensor a (12800) must match the size of tensor b (100) at non-singleton dimension 0
输入维度为12800,输出维度为100,输入输出的维度不一致,正确的例子如下:
- inputs = [(1,2,3), (2,3,4)]
- outsputs = [4, 5]
将输入输出的长度改为一致
取tensor的第一个元素
XXX.item() # XXX为tensor对象
tensor中的元素改变数据类型
- # 常常因为数据类型出错,要修改数据类型
- XXX.int()
- XXX.float()
(未完待续)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。