I am getting operand mismatch error when i run my nn_model function which calls “forward_propagation”, i have used matmul operator to multiple W and X
I have been getting the right expected value until this step, however im stuck here
I have alternatively tried using np.dot , np.multiple and W@X.
I also tried creating another function forward_propagation_one where i changed up a few things and called that from nn_model
However, absolutely nothing is working
Please help
Find below attached the error
I’m not a mentor for that course.
But I suggest you look at the difference between np.matmul() and np.dot().
Have you checked the shapes of W and X?
Hi @jonrico , Thanks a lot for the reply
Yes I checked that W is of the shape (1,1) and X is (1,30)
If I’m not wrong, I cannot matrix multiply using matmul, 1x1 and 1x30 , which is why i tried using matmul(W,X.T) which is multiplication between a 1x1 and a 30x1
However, my code shows error for matmul (W,X.T) and shows correct answer for matmul(W,X); which shouldn’t be possible right?
Surprisingly I am also getting the expected values in all of the codes except in the “nn_model”
Thank you again
Hi thank you for the reply,
Yes I do know the difference to some knowledge, which is why I went with the np.matmul initially cuz I didnt want any messups later, and to my knowledge np.matmul follows matrix multiplication rules to the point right? Anyways i did np.matmul(W,X.T) for which i got mismatch error (W - 1x1 ; X - 1x30)
I simply tried the other operators such as np.dot as I was stuck, but none of them helped
Please correct me if I’m wrong
@jonrico I just solved the problem
I called the initialize_parameters function to define parameters in the nn_model function instead of just assigning values of W and b like parameters = {“W”: [[43.63366703]], “b”: [[0.17926448]]} and it solved the problem !
I’m guessing the dimensions were not proper when I defined W and b with their values and were indeed proper when i called them using intialize_parameters?
Is this right? Was this why it didnt work
Nice! That should be the way to do it. You were supposed to use your previously built functions.