Printing tensor sometimes returns shape of the tensor in Pytorch
So I have this tensor called bids, and I try to filter some values of it for debugging purposes. However, some filters do return the filtered tensor, and some return the shape of the tensor as shown below:
bids[bids&gt;=0]
&gt; tensor([0.6249, 0.2195, 0.1606,  ..., 0.1114, 0.2826, 0.8744],
       grad_fn=&lt;IndexBackward&gt;)
bids[bids&lt;0]
&gt; tensor([], grad_fn=&lt;IndexBackward&gt;)

bids[bids=='nan']
&gt;tensor([], size=(0, 1024, 2, 1), grad_fn=&lt;IndexBackward&gt;)

Does anybody have any idea why this happens? Thanks in advance!

That's because the result from the masking operation is empty (notice how one of the dimensions is equal to zero). The reason is you have no elements in bids that equal 'nan'. In turn, this makes the mask bids == 'nan' comprised of only zero values.
Here is a minimal example:
&gt;&gt;&gt; bids = torch.arange(10)
&gt;&gt;&gt; bids[bids=='nan']
tensor([], size=(0, 10), dtype=torch.int64)

