pytorch convert tensor type code example
Example 1: cast tensor type pytorch
y = y.to(torch.long)
# torch.long, torch.int16, torch.int32, torch.float16, etc.
Example 2: pytorch convert tensor dtype
x.type(torch.DoubleTensor)
y = y.to(torch.long)
# torch.long, torch.int16, torch.int32, torch.float16, etc.
x.type(torch.DoubleTensor)