Course 4 Week 4 Assignment 1 Question

I have a similar issue as Mun_Chung_Wong and i have gone through my code but can’t spot the error.

Both distances L2 norms are reduce_sum with axis=-1.
Final loss is computed with default no axis.
I used tf arithmetic for all computation

I can share my code if that will help

Note that there are no L2 norm functions involved here. It is the square of the L2 norms, right? So you can compute that more efficiently as simply the sum of the squares of the elements.

Also note that the sum of the maxima with zero is not the same thing as the maximum of the sum w.r.t. 0.

Here’s another thread which discusses why the order of operations has the sum as the last operation.

1 Like

Thanks Paul.

I did the calculation manually without using the L2 norm.
I had computed the sum of the loss, before comparing the maximum of it and 0.

It’s all good now