当前位置:   article > 正文

使用pytorch遇到的各种问题及解决方案_runtimeerror: the size of tensor a (12800) must ma

runtimeerror: the size of tensor a (12800) must match the size of tensor b (

自己在使用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,输入输出的维度不一致,正确的例子如下:

  1. inputs = [(1,2,3), (2,3,4)]
  2. outsputs = [4, 5]

将输入输出的长度改为一致

 

tensor的第一个元素

XXX.item()  # XXX为tensor对象

 

tensor中的元素改变数据类型

  1. # 常常因为数据类型出错,要修改数据类型
  2. XXX.int()
  3. XXX.float()

(未完待续)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/272332
推荐阅读
相关标签
  

闽ICP备14008679号