I am trying to convert numpy array into PyTorch LongTensor type Variable as follows:
import numpy as np
import torch as th
y = np.array([1., 1., 1.1478225, 1.1478225, 0.8521775, 0.8521775, 0.4434675])
yth = Variable(th.from_numpy(y)).type(torch.LongTensor)
However the result I am getting is a rounded off version:
tensor([ 1, 1, 1, 1, 0, 0, 0])
How can I keep the precision of numpy array while getting LongTensor variable?
Expected result should be:
tensor([1., 1., 1.1478225, 1.1478225, 0.8521775, 0.8521775, 0.4434675])