How to append tensors

How can we append tensors
So my situation is I have a for loop that goes through all rows from a 2-D tensor and then does argmax in each row, and returns a tensor position of the maximum value in that row. And finally, I want to append all those a value and creates a 1-D tensor
How can I achieve that

If you want to get the maximal indices for each row, you could just call .argmax(1):

x = torch.randn(10, 15)
x.argmax(1)
1 Like

thank you @ptrblck
it works

1 Like