大佬教程收集整理的这篇文章主要介绍了声明为 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
@H_403_9@我可能犯了一些愚蠢的错误。
为什么会这样?
编辑:
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
@H_403_9@就我而言,
a
是edge_index
。解决方法
从 the documentation 中@R_489_6380@
torch.long
和torch.int64
是同义词,都指代 64 位有符号整数类型。
以上是大佬教程为你收集整理的声明为 torch.long 的 PyTorch 张量变成了 torch.int64全部内容,希望文章能够帮你解决声明为 torch.long 的 PyTorch 张量变成了 torch.int64所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。