当我尝试运行以下简单的行时,我遇到一个非常奇怪的错误:
\na = torch.Tensor([0,0,0],dtype = torch.int64)\n\nTypeError: new() received an invalid combination of arguments - got (list, dtype=torch.dtype), but expected one of:\n * (*, torch.device device)\n didn't match because some of the keywords were incorrect: dtype\n * (torch.Storage storage)\n * (Tensor other)\n * (tuple of ints size, *, torch.device device)\n * (object data, *, torch.device device)\n
Run Code Online (Sandbox Code Playgroud)\n而如果我们查看官方文档
\ntorch.tensor(data, dtype=None, device=None, requires_grad=False, pin_memory=False) \xe2\x86\x92 Tensor\n
Run Code Online (Sandbox Code Playgroud)\n\n\n …参数
\ndata (array_like) \xe2\x80\x93 张量的初始数据。可以是列表、元组、NumPy ndarray、标量和其他类型。
\ndtype(torch.dtype,可选)\xe2\x80\x93 返回张量所需的数据类型。默认值:如果无,则从数据推断数据类型。
\n