Course 2, Week3, Tensorflow with regularization

I have a question on Tensorflow with regularization.
In Course 2, week3 HW builds model by using Tensorflow GradientTape.
It doesn’t touch regularization in this homework but I want to add L2 regularization in the model.
Can I do it by modify only cost function by adding L2 regularization term and leave other code untouched?
I think adding only L2 term in cost function can handle the regularization since GradientTape can handle rest of the part.
But if I have to modify any other part or miss anything, feel free to comment.
Thanks,

Hi, @Justin.

Your understanding seems correct to me. Just add the penalty term to minibatch_cost.

Have fun experimenting :slight_smile:

Noted. Great Thanks Nramon

1 Like