C3W?_Assignment: Question Duplicates error in comment of GRADED FUNCTION TripletLoss Fn

In the new (12/2023) TensorFlow version of the Assignment “Question Duplicates” for the last week of NLP with Sequence Models there’s an error in a comment suggestion in the TripletLoss Fcn. The key part is written as:

But if you do that, the mean_negative value will be too large and cause the Triplet Loss to be ~ 2.4 AND the code won’t pass all the unittests.

The comment suggestion just before mean_negative should read with a zero, 0, for the axis as in the key part of the comment:

When the course got upgraded to the TensorFlow version this week, the number of weeks in the course dropped from 4 to 3. As I had already completed the first 3 weeks I’m not worried but the assignment is showing up for me as the C3W3_Assignment in the notebook–if you have 4 weeks of the course it should be C3W4_Assignment.


I actually used the suggested axis of 1 and my code passed all the unit tests.

Just ran my notebook again with axis of 0 and code passed all the tests.

I tried running it with with axis of 1 and got the following for unit tests:

A little puzzled given that, from what I can see, the cell isn’t using a previously defined function in which I have have chosen the wrong axis…not sure why axis = 0 works for my notebook and not others…

Just check if you can pass the complete lab, meaning that your function does not affect anything down the line. Otherwise, a mentor may have to help out here.

I’m lucky because with the axis = 0, the assignment got 10/10 points for the TripletLossFn section.

Thanks lukmanaj for the good caution/advice!

Good to know. Did you complete the lab successfully?
I think it has to do with how some of the earlier local variables in the function were defined. That’s why different axis worked.

Yep, I got 100% on the assignment. I looked for about an hour and couldn’t see where I had earlier defined variables that would have “flipped” the data; but, I did firm up my understanding of the concepts and Python code by looking for the possible variable definition :slight_smile:

1 Like

Nice. There’s always a silver lining. And the course people can always look into it.