I am getting this error, plz help
That error is being thrown by the + operation on the RHS of that statement. So that means you have two problems:
The result of w^T \cdot X is 2 x 3, but it should be 1 x 3.
And b is 2 x 2, but it should be a scalar.
So how did that happen? Note that the bug is not in propagate
, because it does not change the shapes of any of those variables: they are just inputs.
My guess would be that it is the “update parameters” logic that is probably wrong.
Try putting some print statements like this in optimize
, right before the call to propagate
:
print(f"w.shape = {w.shape}")
print(f"X.shape = {X.shape}")
print(f"b = {b}")
What does that show? My prediction is that the shapes will be correct on the first iteration, but not on the second.
After using the print statement you suggested, this the output I am getting.
Your are right the first iteration the shapes seems to be right and then it is messed up.
I figured it out. By mistake, I used w in place of b for update parameters.
Thank you, Paul