ReLU Prime with NumPy array

Viewed 4555

I want to pass a multidimensionnal array into the relu prime function

def reluprime(x):
    if x > 0:
        return 1
    else:
        return 0

... where the x is the whole array. It returns

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I've had this problem with the normal relu function, and instead of using the python function max() I used np.max() and it worked. But with the relu prime, it is not working either way. I tried:

def reluprime(x):
    if np.greater(x, 0):
        return 1
    else:
        return 0

... and it still returned the same error. How can I fix this? Thank you.

3 Answers
Related