Feedback on Week 3 Practice Lab, Exercise 5

Firstly, thanks for the great course. It’s fantastic and especially love the interactive plots.

On Exercise 5 for the Week 3 Practice lab, the instructions were to calculate the regularization term:

\frac{\lambda}{2m} \sum_{j=0}^{n-1} w_j^2

The instructions mention that this computed term will be added to the computed cost without regularization. But, in the code, the (lambda_/(2 * m)) term is calculated and multiplied against the reg_cost:

    ### START CODE HERE ###
    ### END CODE HERE ### 
    # Add the regularization cost to get the total cost
    total_cost = cost_without_reg + (lambda_/(2 * m)) * reg_cost

The impression I got from the wording was that the students should calculate both the lambda and sigma terms (and in exercise 6 calculating both is required). Just wanted to make sure this was intentional.

Thanks again.

Hello James @kayvr,

The idea is this:

Total cost = cost without regularization + cost from regularization

In exercise 2 you already implemented compute_cost which will do the “cost without regularization” part, and so what’s missing is the “cost from regularization” part. This is why the description says

The starter code then adds this to the cost without regularization (which you computed above in compute_cost ) to calculate the cost with regulatization.

and in the starter code it has this line that you also quoted

total_cost = cost_without_reg + (lambda_/(2 * m)) * reg_cost

The “cost from regularization” part is the equation that you quoted, and to calculate it, we need to use \lambda (or lambda_) and m, and we need to compute the summation part reg_cost which is what the assignment is about. All these elements are essential for getting the “cost from regularization” part.