RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got CUDAFloatT
程序员文章站
2022-06-13 08:00:42
...
使用torchsummary 中的 summary函数时,模型中有Embedding层的时候,会报错。原因是Embedding 需要整型的Tensor。
这么使用即可:
from torchsummary import summary
summary(model, (1, 100, 8), dtypes=[torch.LongTensor], device='cpu')
pip install 的torchsummary 不行,没有dtypes这个参数。
所以你下载这里提供的 torchsummary.py 放在你的代码一个目录里即可。
链接: https://pan.baidu.com/s/1HKUZi7Eps1KaA0KvPWfO6A
密码: vku4
上一篇: JAVA的23种设计模式之原型模式
下一篇: RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got torch.IntT
推荐阅读
-
RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got CUDAType
-
RuntimeError: Expected object of scalar type Long but got scalar type Int for argument #2 'target'
-
RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got CUDAFloatT
-
RuntimeError: Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got torch.IntT
-
Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got torch.cuda.FloatTensor i
-
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target'
-
RuntimeError: Expected object of scalar type Long but got scalar type Float for argument #2 'target'
-
Expected tensor for argument #1 'indices' to have scalar type Long;but got torch.IntTensor instead