Pytorch equivalent of

Hi guys. Are there any equivalent function for in PyTorch where it can suppress the rows and/or columns of a 2-D array that contain NAN value

Of course I can loop through each dims and check for NAN but that will be very inefficient. Thanks for checking by.

You could create mask tensors using torch.isnan, torch.isinf, and torch.isfinite.
Depending on the desired output, you could check the results in specific dimensions or apply the mask directly.

Sure, I will use torch.isnan but the dropping row or cols part seems inefficient if the matrix have huge shape

That’s interesting to know. Do you know what would make this operation inefficient and how numpy’s approach solves it?

:3 I’m not really sure. I will do some more test and report the result back soon