Boolean value of Tensor with more than one value is ambiguous when idexing

Hello advance sorry for being noob. I am currently doing a cnn scratch project. Here in maxpooling class in backpropagation the condition for the indexing is giving error of boolean ambiguous. I am giving the screenshots below!

Screenshot - 10_15_2021 , 9_41_37 PM|690x322

here is the error

The error is raised if you are trying to use more than a single bool value in an if condition:

x = torch.tensor([True, False])
if x:
    print('lala')
# > RuntimeError: Boolean value of Tensor with more than one value is ambiguous

Depending on your use case, you might want to use .any(), .all(), or split the tensor to take different code paths.

Thanks. I have tried without using if condition. Now it works fine !