I’m stuck on section 4.3 L_model_forward
I get the error:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-80-10fc901e800a> in <module>
1 t_X, t_parameters = L_model_forward_test_case_2hidden()
----> 2 t_AL, t_caches = L_model_forward(t_X, t_parameters)
3
4 print("AL = " + str(t_AL))
5
<ipython-input-79-8ad15709ebfe> in L_model_forward(X, parameters)
41 # YOUR CODE STARTS HERE
42
---> 43 AL, cache = linear_activation_forward(A, parameters['W' + str(l)], parameters['b' + str(l)], 'sigmoid')
44 caches.append(cache)
45 # AL, cache = linear_activation_forward(A, parameters['W' + str(l)], parameters['b' + str(l)], activation='sigmoid')
<ipython-input-61-86db2fd9a9de> in linear_activation_forward(A_prev, W, b, activation)
22 # A, activation_cache = ...
23 # YOUR CODE STARTS HERE
---> 24 Z, linear_cache = linear_forward(A_prev, W, b)
25 A, activation_cache = sigmoid(Z)
26
<ipython-input-59-ef0b4f29e360> in linear_forward(A, W, b)
19 # YOUR CODE STARTS HERE
20
---> 21 Z = np.dot(W,A) + b
22
23 # YOUR CODE ENDS HERE
<__array_function__ internals> in dot(*args, **kwargs)
ValueError: shapes (4,5) and (4,4) not aligned: 5 (dim 1) != 4 (dim 0)
I know it means that my dimensions are incorrect, but it does not make any sense to me. I’ve tried to get the transpose of the weight matrix, but then I get a broadcasting error with b
. This is for the sigmoid section.
Any suggestions greatly appreciated