ValueError Traceback (most recent call last)
in
4 hparameters = {“stride” : 1, “f”: 3}
5
----> 6 A, cache = pool_forward(A_prev, hparameters, mode = “max”)
7 print(“mode = max”)
8 print("A.shape = " + str(A.shape))
in pool_forward(A_prev, hparameters, mode)
68
69 if mode == “max”:
—> 70 A[i, h, w, c] = np.max(a_prev_slice)
71 elif mode == “average”:
72 A[i, h, w, c] = np.mean(a_prev_slice)
<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)
2666 “”"
2667 return _wrapreduction(a, np.maximum, ‘max’, axis, None, out,
→ 2668 keepdims=keepdims, initial=initial, where=where)
2669
2670
/opt/conda/lib/python3.7/site-packages/numpy/core/fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
88 return reduction(axis=axis, out=out, **passkwargs)
89
—> 90 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
91
92
ValueError: zero-size array to reduction operation maximum which has no identity
I can tell from the error that my a_prev_slice has some shape issue , I think it’s from slicing poorly but I am unable to find a mistake in it.
I am slicing the first two from the start to end and the third one ‘channel’ from c to c to make sure I only use 1 channel at a time while pooling.
I think the issue is somewhere here. But I can’t put a finger on it.