How to append a tenor to another torch:: Tensor

Hi, Experts,

I am trying to append a tensor to another tensor in pytorch it is:
data.append(datum.numpy())
labels.append(label)

In libtorch, I use
data.append=datum;
labels.append=label1;

And it shows errors . Any comments or suggestions ? Thanks.

append is not a method of the tensor, but a Python list in your example.
In C++ you can create a std::vector<Tensor>& tensors and use torch::stack(tensors) instead.

1 Like

Thanks, that is very helpful