I solved some issues that were happening in my code and then this issue came up, can anyone help me? I think I should reshape it but I dont know how
Check how are you calling the optimization i.e (order you are following) for parameters, grads and costs.
params, grads, costs = optimize(w, b, X, Y, num_iterations=100, learning_rate=0.009, print_cost=False)
THis is the lie of code, is it correct?
Please use all “passed” parameters like X_train, Y_train, num_iterations, ,…
I guess you initialize w , b with the shape of X as well.
X and Y are global variables, not parameter passed to model()
This makes the shape of w to (2,1) which can not be reshaped to (4,1).
Nobu is right. You need to specify all the parameters clearly.
Hi, I did what you recommended( I think) and this problem pops up, my first instinct is that I should reshape/transpose something but I feel a little lost
The value (1/m) must be implemented for all the terms. This is also making a lot of difference in the results.
so I should add the 1/m before the optimize function?
No, check the way you are writing it down.
As I wrote in my previous response, I guess you set the shape of X for initialization. You need to use, of course, X_train.
Did you mean only in the exercise 8 cell or in every previous cell? Because in the exercise 8 cell I already changed the X to x_train as recomended
Did you mean only in the exercise 8 cell or in every previous cell?
No. everything has a scope. We are just talking about inside model()
Have you checked the dimension of w ?
The error message said that the shape of your w is (2,1) and X is (4,7).
(1,2) means the shape of w.T. Dot product does not work for those shape.
At first, after initialization or even before initialization, please check your parameter that you pass to w. You need to pass 4, but, seem to pass 2, which is same as the first dimension of X.
Anyway, please check the shape of w.
Here is what w is defined as, per the exercises instructions. Should I add another value to w?
No, what we are talking about is the “shape” of w that you initialized in model().
As you see, the error occurred in propagate(). From the error message, the shape of w is not correct. And, it was set in model() by initialize_with_zero(). The first dimension of w and X\_train needs to be the same value so that dot product works in propagate().
Oh I see, I did the initialize with zeros function, and when I tried to initialize w as X_train.shape it marked as an error
OK, you are very close to the final code.
Just one confirmation… Passing a tuple, like (a,b), does not work for initialize_with_zero(). And, X_train.shape returns a tuple. You need to select the first dimension.
Yes actually i had the error popping up saying ‘tuple object is not callable’ So I am still trying to see how to remove that error. In the initialize with zeros I have as a parameter ‘dim’
“dim” is terrible. It is a global variable set for the test of initialize_with_zero() function. As dim=2, then, the shape of your w is (2,1). That’s the reason.
What you need to do is to extract the value of the first dimension from a tuple returned from “shape”.
That sounds like you are using the wrong syntax to index the shape tuple. If you use parens, then python thinks you are making a function call. If you want to index an array, list or tuple, you need to use square brackets.
Thanks, that cleared the error but now it says again its unalligned
and marks the error in the line optimize, but I don’t think thats where the issue is at. My best guess is that I did something wrong with the shape. Sorry for the inconviniences I’m barely beginning to understand everything in this course