Help on TensorDataset in libtorch please

Hi, All

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

In python it is:

From import TensorDataset

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

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


The dataset part is straightforward, see the class here:

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.

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))
t.size() to check the col and row.