I didi do not worry… I was asking my self how it was possible since i declare the variable after that line… but anyway it works
OK. Now, what is the shape of theta_plus
and what is the shape of theta_plus[i]
?
I already answered is not correct?
I should take
theta_plus[i][0] right?
@Luca_De_Renzo, your shapes are not correct.
Use these print lines instead
print('theta_plus', theta_plus.shape)
print('theta_plus[i]', theta_plus[i].shape)
Then share a screenshot of the printed outputs here.
I will not tell you what you should do to finish your assignment. I can only walk through the error message with you, and you will need to figure out what to do based on the error message, and the assignment’s text description. It is your assignment
No. It is not exactly the same. You swapped the two.
It was because I was in a hurry
But anyway my other question was… shouldn’t be theta_plus already a vector?
It’s okay. The key is we need to know the fact. With the fact, you can start thinking about why you would assign an array of (47,1) to theta_plus[i]
which is supposed to have a shape of (1)
(essentially a scalar).
Go back to the assignment’s description to figure out what is needed for theta_plus[i]
It is a 2D array of shape (47, 1). You saw it.
A 2D array means a matrix … and I thought that the function dictionary_to_vector() would have transformed it in a 1D array
I am sorry but I do not get
But you need a 2D array to represent a column vector, don’t you?
But is exactly why I am getting the error is because is a column vector
of 47 rows and 1 column … I should reshape it then
Make sure to read carefully the assignment’s description, and you should be able to figure out how to implement it correctly. You are not implementing it as instructed.
There is no need to reshape. You just need to implement it as instructed.
I have to go now. You really have not implemented step 2 in my above screenshot as instructed. Read it out loud if it can help. Read all the subscripts. There are two subscripts.
Good luck @Luca_De_Renzo
Raymond
Thks Raymond I appreciated but do not get it
I did the second step
Anyway I do not want You to go nuts
Many thks
Nobody needs to go nuts. Don’t hurry @Luca_De_Renzo . You have spotted the two mistakes earlier which is great, and you should be able to spot the difference between \theta_i^+ and \theta^+. I have to go now, and perhaps you might also take a leave for an hour and come back to look at the step 2 again? Sometimes, a change of focus can help.
Goodbye!
Seems that I found the solution, even if with the error “difference = 0.2850931567761623”; but 2 question:
theta_plus[i]= theta_plus[i] -epsilon ← why am I doing this?
and more…
gradapprox[i]= (J_plus[i] - J_minus[i]) / (2 * epsilon) ← why am I calculating if do not use to find the difference?