如何解决声明为 torch.long 的 PyTorch 张量变成了 torch.int64
我是 PyTorch 的新手,所以我对 PyTorch Tensors 的工作并不多。我感到困惑的是,如果我将张量的 dytpe 声明为 torch.long
,然后检查它的 dtype 为 int64
。例如:
In [62]: a = torch.tensor([[0,1,2],[1,2,1]],dtype=torch.long)
a.dtype
Out[62]: torch.int64
我可能犯了一些愚蠢的错误。
为什么会这样?
编辑:
89 if isinstance(edge_index,Tensor):
---> 90 assert edge_index.dtype == torch.long
91 assert edge_index.dim() == 2
92 assert edge_index.size(0) == 2
就我而言,a
是 edge_index
。
解决方法
从 the documentation 中我们可以看到 torch.long
和 torch.int64
是同义词,都指代 64 位有符号整数类型。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。