Help me to solve error in NN_basics_week_2_assignment

Please

{moderator edit - solution code removed}

getting error related assert(dw.shape == w.shape)
they are now matching.

please anyone help me to solve it, :slight_smile:

@Ranjeet_Kumbhar1 Um… So sharing code is against forum rules (sorry).

And I am not one to download/run random code from even welling meaning strangers.

Can you share a screenshot of the error you’re getting ?

The calculation of dw in the propagate function depends on the variables X, y, and w. If the shape of these is incorrect, it may occur that the shapes of w and dw are different. In the model function, plot the shapes of these to find out which is the incorrect shape.

I hope you are not planning to submit that notebook to the grader. You’ve made a bunch of changes and that will not end well.

I added some instrumentation to your model function and the propagate function to show the shapes. Here’s what I see:

in model: X.shape (12288, 209) w.shape (12288, 1)
in propagate: w.shape (12288, 1)
in propagate: dw.shape (12288, 209)

So the dw shape is clearly wrong. I didn’t look that hard, but the propagate logic looks correct to me. So why does it work when you run the optimize function by itself, but not when you call optimize from model. It must have to do with the arguments you are passing in the model case.

Update: yes, one of the arguments you are passing is incorrect.

3 Likes

Yes, you’re right. I am passing two different X in the propagate and model functions and am still trying to solve the issue, currently passing train_set_x for both functions. Let’s see

super cool assignment
Thanks!!!

I am new here; I will get to know the rules soon.
Thank you

@Ranjeet_Kumbhar1 that is okay. To be honest I don’t ‘love enforcing them’ (and actually can’t)-- But know someone will so just giving you a ‘heads up’ :wink:

1 Like

The incorrect parameter is not what you would expect. It’s not the X value that is the wrong shape.

Also if you are considering this as the assignment in DLS C1 W2 and want to submit it for a grade, you are making a huge mistake by completely rearranging the notebook. Notice that you even changed the function name of the initialization function. That will never work with the grader.

I’m guessing that you are running this in your own environment, because you even changed the pathnames and the directory structure. So that’s fine if you are just treating this as an interesting learning experience and don’t care about the grade in the course.

yes,
I am not going to submit this assignment, am doing this assignment for my learning.

1 Like