声明为 torch.long 的 PyTorch 张量变为 torch.int64
PyTorch tensor declared as torch.long becomes torch.int64
我是 PyTorch 的新手,所以我没有太多使用 PyTorch 张量。我感到困惑的是,如果我将张量的 dytpe 声明为 torch.long
,然后检查 dtype,它是 int64
。例如:
In [62]: a = torch.tensor([[0, 1, 1, 2],
[1, 0, 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位有符号整数类型。
我是 PyTorch 的新手,所以我没有太多使用 PyTorch 张量。我感到困惑的是,如果我将张量的 dytpe 声明为 torch.long
,然后检查 dtype,它是 int64
。例如:
In [62]: a = torch.tensor([[0, 1, 1, 2],
[1, 0, 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位有符号整数类型。