欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

TypeError: new() received an invalid combination of arguments-got(float, int)

程序员文章站 2022-05-27 12:40:17
...
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/zhangboshen/anaconda3/lib/python3.6/site-packages/torch/nn/modules/linear.py", line 48, in __init__
    self.weight = Parameter(torch.Tensor(out_features, in_features))
TypeError: new() received an invalid combination of arguments - got (float, int), but expected one of:
 * (torch.device device)
 * (torch.Storage storage)
 * (Tensor other)
 * (tuple of ints size, torch.device device)
      didn't match because some of the arguments have invalid types: (float, int)
 * (object data, torch.device device)
      didn't match because some of the arguments have invalid types: (float, int)

这个问题确实是由于‘/’的问题,需要将其换成‘//’,但也要注意换成之后,也就是取整,会破坏原来的结构。
TypeError: new() received an invalid combination of arguments-got(float, int)