Perform filtering on N Dimensional numpy array

I have two N dimensional array, the dimension of both arrays are same.

  1. a = (n,n,52)
  2. b = (n,n,52)

I am trying to filter each of (n,n) array in variable a with (n,n) array in variable b. I am trying this using command

b[a==0 | a>5] = 1

But I am getting following error

IndexError: boolean index did not match indexed array along dimension 2; dimension is 52 but corresponding boolean dimension is 1

I need some help in figuring out as how to filter one N dimensional array using another.

Source: Python Questions