I have a pytorch tensor and want to mask part of it and put the masked section in an if statement. This is my tensor:
import torch
all_data = torch.tensor([[1.1, 0.4],
[1.7, 2.7],
[0.9, 0.7],
[0.9, 3.5],
[0.1, 0.5]])
if [(all_data[:,0]<1) & (all_data[:,1]<1)]: # I have two conditions
print ('Masked')
else:
print('Not_Masked')
this piece of code is not working correctly because it prints the whole tensor while I want to check the tensor row by row: the first and second rows do not fulfill the condition and I want to print Not_Masked
. The third row fulfills and I wan to have Masked
printed. It should go so on and so forth.
I appreciate any help.