Hello there!
I am not sure if it is ok to add to posts instead of creating a new one, but I am having exactly the same issue as @Edu4rd .
I also searched all similar comments and followed the advice provided by @TMosh here: Week 1 course 4 Programming Assignment 1 - #2 by TMosh (adding np. to the float).
Unfortunately, this did not work for me. I am also continuing to get the following message:
only size-1 arrays can be converted to Python scalars
However, the value I am getting back is already a scalar:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-22-182241fd5e53> in <module>
6 "stride": 2}
7
----> 8 Z, cache_conv = conv_forward(A_prev, W, b, hparameters)
9 print("Z's mean =\n", np.mean(Z))
10 print("Z[0,2,1] =\n", Z[0, 2, 1])
<ipython-input-21-7ac1ac8c5e0d> in conv_forward(A_prev, W, b, hparameters)
97
98 print(f'Z{i},{h},{w},{c}')
---> 99 print(f'conv_single_step func -> {conv_single_step(a_slice_prev, weights, biases)}')
100 Z[i, h, w, c] = conv_single_step(a_slice_prev, weights, biases)
101
<ipython-input-19-0dc5d6ead47d> in conv_single_step(a_slice_prev, W, b)
26 s = a_slice_prev * W
27 Z = np.sum(s, dtype=np.float)
---> 28 Z += np.float(b)
29
30 # YOUR CODE ENDS HERE
TypeError: only size-1 arrays can be converted to Python scalars
The value of Z at crashing time is:
conv_single_step func -> 1.5592957225103126
So why is the tester saying that the result of the function is a non-size-1 array?
(By the way, this previous function passed the tester before).
Thank you for any pointers. Also, I can create a different posting if this was the expectation.