Chen0729
(Steven)
1
Hi, All, I have met an issue about converting the following from pytorch to libtorch (C++)
In pytorch it is:
return loss.data.cpu().numpy()
I write in C++ as:
return loss.data.cpu().numpy();
I get error no member “numpy()” for at::Tensor
Any suggestions ?
Much appreciated
You cannot transform the tensor to a numpy array, since numpy doesn’t have a C++ API.
Chen0729
(Steven)
3
Thanks.
So I will just convert it as: return loss.data().cpu();
Are they the same in this case ?
Best,
Xu
a_d
4
Yes, but with the catch that you would still be returning a tensor.