Since your compute_cost function passed its test in UNQ_C2, we can reasonably assume that your cost function implementation is correct when no regularization is involved (cost_without_reg). The problem seems to occur when adding the regularization cost reg_cost to get the total_cost in the compute_cost_reg function, particularly in UNQ_C5.
Ensure that the regularization term reg_cost is calculated correctly (the regularization factor should be applied to the entire sum after summing the squares of all weights) and included in the final cost along with the original cost:
Indeed there was an issue, I was adding the reg cost incorrectly and besides there was an indentation problem in the Python code that was not registered as an error ( curse you Python indentation! haha)
now the test passed correctly
posting codes related to your graded assignment is against community guidelines, kindly refrain from it. You can always share when a mentor wants to see your codes by personal DM
@pepspro the indentations can perhaps be a little annoying to remember-- but you’ll much appreciate them because they are relatively easy to see, and it is not like C, where maybe you forgot a semi-colon and have no idea where.
Thank you for following the Community Guidelines! In the future, if you need to share code, feel free to describe the problem or ask for advice without posting the full code, or use more private means like direct messaging if a mentor wants to see your code