How to apply conditions for rows in a tensor where there is boolean values
I have the following tensor:

predictions = torch.tensor([[ True, False, False],
                            [False, False,  True],
                            [False,  True,  True],
                            [ True, False, False]])


I applied conditions along the axis like below.

new_pred= []

if predictions == ([True,False,False]):
       new_pred = torch.Tensor(0)
if predictions == ([False,False,True]):
       new_pred = torch.Tensor(2)
if predictions == ([False,True,True]):
       new_pred = torch.Tensor(2)


So I want the final output (new_pred) to be:
tensor([0, 2, 2, 0])

But I am getting a blank [] for the new_pred tensor. I think my logic must be flawed since nothing is getting stored in the new_pred. Can someone help me write this logic accurately? 

The type of predictions is torch.Tensor while ([True, False, False]) is a list, first, you have to make sure both sides have the same type. 

predictions == torch.tensor([True,False,False])
&gt;&gt;&gt; tensor([[ True, True, True],
            [False, True, False],
            [False, False, False],
            [True, True, True]])


Then, you are still comparing a 2d tensor to a 1d tensor, which is ambiguous in an if statement, an easy way to fix this would be to write a for loop, compare each row of the predictions to the conditions and append the result to the new_pred list. Note that you will be comparing two booleans tensors with the size of three, therefore, you have to make sure the result of the comparison is True for all of the cells. 

predictions = torch.tensor([[ True, False, False],
                            [False, False,  True],
                            [False,  True,  True],
                            [ True, False, False]])

conditions = torch.tensor([[True,False,False], 
                            [False,False,True],
                            [False,True,True]])
new_predict = []
for index in range(predictions.size(0)):
    if (predictions[index] == conditions[0]).all():
        new_predict.append(0)
    # ...


Alternatively, you can use slicing to achieve your expected result without any for loop. 
