I have a float number saved to A, as follows, I wish I can convert it to torch.autograd.variable. Searching the interent I found i can do the following, but now after doing the following, when I print the value of the B (which is the converted number) it does not show me anything.
Any suggestion?
A= np.float64(0.85210)
print(A)
print(type(A))
Output:
0.8521
<type ‘numpy.float64’>
Then for converting I do:
B=(Variable((torch.from_numpy(np.array(A, dtype=np.float64))).cuda()))
print(B)
print(type(B))
and the output is:
Variable containing:[torch.cuda.DoubleTensor with no dimension]
<class ‘torch.autograd.variable.Variable’>
P.S. the reason I convert to np.array first is because using torch.from_numpy(A) giving me the error that :
RuntimeError: from_numpy expects an np.ndarray but got numpy.float64