Help on TensorDataset in libtorch please

Hi, All

I have inquiry about conversion of TensorDataset to C++,

In python it is:

From torch.utils.data import TensorDataset

return TensorDataset(torch.FloatTensor(np.array(data)),
torch.LongTensor(np.array(labels))

May I ask what is the best way to convert it in c++ please ?

Thanks,

Hi,
The dataset part is straightforward, see the class here:
https://github.com/pytorch/pytorch/blob/393ad6582d1876dc995925ef558ba94e954d115e/torch/csrc/api/include/torch/data/datasets/tensor.h

But you need to somehow convert the data/labels in np.array in to a c++ array or vector. Then you can use from_blob to convert them in to a tensor.

Thanks. I have converted them into tensor already.
One issue is that from_blob needs three input argument, and the second argument are img.col and img.row which I donot have here.

@Chen0729
If you previously convert it into np.array, then you can check the np array size, right?
Then you know what is the col and row.
Or, in python, you can do
t = torch.FloatTensor(np.array(data))
then
t.size() to check the col and row.