dtype=torch.long报错怎么办

import torch
x = torch.zeros(5,3 dtype=torch.long)
print(x)
会报错,如果去掉dtype=torch.long就可以了,请问需要调用什么才能不报错

是因为3后面少了逗号吧

你代码是复制黏贴的?

x = torch.zeros(5,3 dtype=torch.long)
改成这样
x = torch.zeros((5,3), dtype=torch.long)

haha,铁子仔细检查检查你的代码