C3 - Week 4: Question about masking in the assignment (in TripletLossFn)

Hi @Harvey_Wang

The “or” operation is pretty simple in mask_exclude_positives it just checks both masks if there is TRUE value in any of them.

When you multiply TRUE value by a number you get that number, 0 everywhere else.

It might be more informative to visualize the operations of your question:

This is a part from TripletLossFn calculation when I wanted to check the " Expected Output" of that exercise. (Where I think the course creators chose a poor batch dimension of 2, so I wanted to check the inner workings when the batch_size is 4).

If you might be interested in full calculations:

So here is the original exercise test (with batch size 2, I remove the solution code lines):

And here is I think better example:

Cheers

7 Likes