pytorch:variable.long()保证64位吗?

问题描述 投票:2回答:1

在pytorch中,我有一个变量,可能是IntTensorcuda.IntTensor。它需要更改为64位保留cpu / gpu。 variable.long()在pytorch的所有实现上都保证64位吗?如果没有,如何将变量转换为64位保留所有实现的cpu / gpu?

type-conversion pytorch tensor
1个回答
0
投票

从PyTorch文档中可以使用heretorch.LongTensortorch.cuda.LongTensor来确保64位有符号整数。

同样,对于64位浮点,您可以使用torch.DoubleTensortorch.cuda.DoubleTensor

您可以使用Variable(tensor)方法将它们转换为变量,其中tensor表示上面创建的张量。

© www.soinside.com 2019 - 2024. All rights reserved.