How to do elementwise max between multiple tensors? getting the following error for 4 tensors

a = torch.ones(1,4,1,1)*2

b = torch.ones(1,4,1,1)*3

c = torch.ones(1,4,1,1)*4

#d = torch.ones(1,4,1,1)*5

max_ = torch.max(a,b,c)

TypeError: max() received an invalid combination of arguments - got (Tensor, Tensor, Tensor), but expected one of:
 * (Tensor input)
 * (Tensor input, name dim, bool keepdim, *, tuple of Tensors out)
 * (Tensor input, Tensor other, *, Tensor out)
 * (Tensor input, int dim, bool keepdim, *, tuple of Tensors out)


Iā€™m afraid the element-wise max will only work for a pair of Tensors, You will have to do them two by two :confused:

1 Like

you can use topk to get the wanted operation