我是stackoverflow的新手,希望这篇文章能尊重所有的要求。
正如在磁贴中一样,我想知道如何将数据类型从torch.int32更改为torch.long,因为我在代码中获得了以下错误:
ValueError:参数edge_index的类型必须为torch.long,但找到的类型为torch.int32。
提前谢谢你。
发布于 2021-07-14 05:16:32
有两种简单的方法可以将张量数据转换为torch.long,它们做的是相同的事情。检查下面的代码片段。
# Example tensor
a = torch.tensor([1, 2, 3], dtype = torch.int32)
# One Way
a = a.to(torch.long)
# Second Way
a = a.type(torch.long)
# Test it out (Should print long version of dtype)
print(a.dtype)萨塔克·贾恩
https://stackoverflow.com/questions/68367265
复制相似问题