AssertionError: Wrong shape for d[‘w’]. (2, 1) != (4, 1)
Can any one help me figure out the error
and the shape w is (2,1) from the beginning and my code worked perfectly during above instances
and the shape w is (2,1) from the beginning and my code worked perfectly during above instances
Well (2,1) may have been the relevant shape for earlier test cases, but it’s not correct for this one. All the code we are writing here is general and should be able to handle any number of features and samples. This type of error usually means you are referencing global variables from the local scope of the model function, instead of the actual parameters which were passed in.
I will re-check the entire code and try to modify it, So you are telling me that am using a global variable instead of the actual parameters to be passed. I will attach a screenshot of the code here I think I messed up while initializing w,b by calling a previous function.
{moderator edit - solution code removed}
Because dim = 2 which was declared earlier, should I initialize the value of w,b without calling ‘initialize_with_zeros(dim)’
Yes, there are several mistakes there:
Please note that this course is not structured as a beginning programming course. You need to have pretty solid competence as a python programmer as a prerequisite in order to succeed here. If you are not familiar with the concept of variable “scope”, you should really consider putting this course on hold and taking an introductory python course first.
The way you compute the predictions is also wrong: you should be calling the predict function for that purpose.
Thanks, Paulin Now my code is perfect.I made the necessary modification as advised by you