I have stacked on the error message ValueError: shapes (1,3) and (4,4) not aligned: 3 (dim 1) != 4 (dim 0) after successfully run L_model_forward(X, parameters) definition. What would be typical checkpoint on those matrix mismatch?
@beachcities sorry, can you a bit more clear ?
I am uncertain if you are getting this error right after running L_model_forward, or later on (because here you say it runs âsuccessfullyâ).
Also, in the future, please make sure to include the course number as well-- I kind of had to hunt around in my files to figure out what notebook we were talking about.
This is Deep Learning Specialization - Neural Networking and Deep Learning, Week 4 A1, but notebook name âBuilding_your_Deep_Neural_Network_Step_by_Stepâ. In 4.3 - L-Layer Model part, coding for L_model_forward(X, parameters) run succesfully, but failed with next code for L_model_forward_test(L_model_forward)
Thanks. I see. Is it possible to take a screenshot of the error you get (with all the errata) ?
Note: just the error, not the code.
Given the specific error, there is a mismatch where the input to a layer (or matrix multiplication) has the wrong shape, or the weight matrix is not sized correctly. There may be an indentation problem in the Python code. Make sure that the second part of your solution code, the activation value of the output (last) layer and the list of caches in the L_model_forward
function, is placed outside the for loop.
That means that your logic for handling the output layer is incorrect. The A_prev
value that you are using as input is incorrect. Take a more careful look at the values that the variables contain when you fall out of the loop over the hidden layers.
Hereâs another recent thread with exactly the same error message. Please read my post there for more info about how to debug this.