Find the biggest of two pytorch tensor on size
How to find the biggest of two pytorch tensors on size
&gt;&gt;&gt; tensor1 = torch.empty(0)
&gt;&gt;&gt; tensor2 = torch.empty(1)
&gt;&gt;&gt; tensor1
tensor([])
&gt;&gt;&gt; tensor2
tensor([5.9555e-34])

torch.maximum is returrning the empty tensor as the biggest tensor
&gt;&gt;&gt; torch.maximum(tensor1,tensor2)
tensor([])

Is there a way to find the biggest tensor among two tensors (mostly 1d), base on the number of elements in the tensor.

Why not comparing their first dimension size? To do so you can use equivalents: x.size(0), x.shape[0], and len(x). To return the tensor with longest size, you can use the built-in max function with the key argument:
&gt;&gt;&gt; max((tensor1, tensor2), key=len)

