# Course2 week4 exercise 4 . TypeError: only integer scalar arrays can be converted to a scalar index

TypeError Traceback (most recent call last)
in
35
36 tmp_m = (2*tmp_C)
—> 37 tmp_grad_W1, tmp_grad_W2, tmp_grad_b1, tmp_grad_b2 = back_prop(tmp_x, tmp_yhat, tmp_y, tmp_h, tmp_W1, tmp_W2, tmp_b1, tmp_b2, tmp_batch_size)
38
39 print()

in back_prop(x, yhat, y, h, W1, W2, b1, b2, batch_size)
19
20 # Apply relu to l1
—> 21 l1 = l1 = np.max(0,l1)
22
23 # compute the gradient for W1

<array_function internals> in amax(*args, **kwargs)

/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py in amax(a, axis, out, keepdims, initial, where)
2704 “”"
2705 return _wrapreduction(a, np.maximum, ‘max’, axis, None, out,
→ 2706 keepdims=keepdims, initial=initial, where=where)
2707
2708

/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
85 return reduction(axis=axis, out=out, **passkwargs)
86
—> 87 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
88
89

TypeError: only integer scalar arrays can be converted to a scalar index

I believe you already messaged with issues regarding this particular assignment. Reply me there and I shall take a look.

Cheers,
Mubsi

Hi, I got the same issue. I solved it defining the function relu into the function back_prop(). The problem was in the np.max() but I did’nt now why.