Week 1 regularization programming assignment


Why i got this?

Because your code is incorrect. Please double-check your code with instructions and hints. If still facing any issue, send me your code in a direct message. Click my name and message.

One common error on this section is to use the wrong PRNG function. Note that in all cases up to this point we’ve used “randn”, which is a normal distribution. But here we need the uniform distribution on [0,1]. That is “rand” instead of “randn”.

Also check that you included the “inverse dropout” compensation by multiplying by 1/keep_prob.

Thank you @Max2001 for sending me your code.
As Paul mentioned, you have used “rand” but the shape is incorrect. Please reread the instructions.

1 Like

Thank you so much!!! I didn’t notice that!

Yes, it’s an interesting point in how Prof Ng has us implement DropOut that in each minibatch every sample is handled differently w.r.t. the dropout mask. This was not clear from the lectures (or at least I don’t remember him discussing this point), but it’s very clear in the instructions in the assignment here. There has been some interesting previous discussion of this point, which is worth a look. That thread even includes some experiments with doing it both ways (same per sample or different per sample).

1 Like