my code:
{Moderator Edit: Solution Code Removed}
input:
np.random.seed(1)
A_prev = np.random.randn(2, 5, 7, 4)
W = np.random.randn(3, 3, 4, 8)
b = np.random.randn(1, 1, 1, 8)
hparameters = {"pad" : 1,
"stride": 2}
Z, cache_conv = conv_forward(A_prev, W, b, hparameters)
z_mean = np.mean(Z)
z_0_2_1 = Z[0, 2, 1]
cache_0_1_2_3 = cache_conv[0][1][2][3]
print("Z's mean =\n", z_mean)
print("Z[0,2,1] =\n", z_0_2_1)
print("cache_conv[0][1][2][3] =\n", cache_0_1_2_3)
conv_forward_test_1(z_mean, z_0_2_1, cache_0_1_2_3)
conv_forward_test_2(conv_forward)
output:
a_slice : (3, 3, 4)
weights : (3, 3)
biases ()
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-65-7e580406a9e8> in <module>
6 "stride": 2}
7
----> 8 Z, cache_conv = conv_forward(A_prev, W, b, hparameters)
9 z_mean = np.mean(Z)
10 z_0_2_1 = Z[0, 2, 1]
<ipython-input-64-4f47a790c95a> in conv_forward(A_prev, W, b, hparameters)
97 biases=b[0,0,0,c]
98 print("biases ", biases.shape)
---> 99 Z[i,h,w,c]= np.sum( np.multiply(a_slice_prev,weights),biases)
100
101
ValueError: operands could not be broadcast together with shapes (3,3,4) (3,3)
- how do i get n_C_prev and n_C for W, b . if c starts from 0 to n_C
- what would be the n_C_prev value?
- how to get W and b and then compute Z ?
- please help, i checked previous forum questions, but i didnt find any answer to the similar doubt