Unable to pass the unit test for the calculation of grad_b1 for Ex 4 in assignment week 4


I am unable to calculate grad_b1, even though my equation seems to be correct, as I have passed all the other unit test except for this one, despite the fact that other equation seems to have a similar format to this one.

Hi @Tyme_Chatupanyachoti

Both cases indicate that you incorrectly implemented grad_b1 calculation (while other calculations are ok). So please check your grad_b1 calculation.


I am having the exact same problem / behavior (output numbers for grad_b1 are the same).

I have been up and down the code 1000 times and can’t see what the problem is. As the OP mentioned, grad_b1 is calculated with very similar parts to both grad_W1 and grad_b2, both of which are passing the unit tests in this case.
I even tried pre-calculating the common factors (yhat-y) and (l1 * z1) into their own variables and sharing those variables for the calculations of grad_b1, grad_W1 and grad_b2 just to see if there was something stupid I was doing, but I’m getting the same result.

Any guidance on this?
(Also, if there any chance that a change has made the unit tests wrong – looks like two identical issues within a week of each other. Just wondering…)
thanks in advance!

Hi @Nate_Blaylock

That is true. In this assignment, to calculate layer 1 parameters’ gradients we use an intermediate variable l1. So if you calculated grad_W1 correctly, there should be no problem calculating grad_b1.

It is hard guide why particularly the grad_b1 but judging by your comment, you don’t need to multiply l1 by z1 when calculating grad_b1 (similarly as you did in grad_W1 calculation).


1 Like

@arvyzukai, thank you!
Switching the grad_b1 to just use l1 instead of l1*z1 did the trick.

I believe the figure at the top of Exercise 4 is wrong, then, since it says to use l1*z1 in grad_b1.

Screenshot 2023-10-27 at 8.13.55 AM

1 Like

Hi @Nate_Blaylock

I agree that the figure is not the most elegant one, but here l1 (the final version of it in calculations) is the everything inside the bracket, not just the first part.

So when calculating grad_b1, you just have to reduce it with the sum (and I agree that the choice of dot 1^T_m is unintuitive notation to indicate the sum :slight_smile:) (and also the choice of using the \cdot here … I don’t know, to me it seems not the right notation, but I’m not the expert here so …)


Thank you @arvyzukai . This comment solved my problem

Thank you guys - I was stuck here for 2 hours!

This must be fixed, or at least supplemented with more explanations.

hi , In backprob i have same issue the error come below

Failed default_check.
[[ 0.56665733]
[ 0.46268776]
[ 0.1063147 ]
[ 0.11041817]
[ 0.32025188]
[ 0.08430878]
[ 0.19341 ]
[ 0.08339139]
[ 0.19055422]
[ 0.56405985]
[ 0.13321988]],
but got:
[0.1063147 ]
[0. ]
[0. ]
[0.19341 ]
[0. ]
[0. ]

Failed default_check.
[[ 0.01864644]
[-0.3564441 ]
[ 0.14815984]
[ 0.25794505]
[ 0.24893135]
[ 0.05895103]
but got:
[0. ]
[0. ]
[0. ]
[0. ]
[0. ]].