C3W3_Assignment - Exercise 02

Yes delete

I clicked ‘Ok’ but still got this message:

@RyeToast

Please follow instruction

at this page delete all the files, once you delete you will find 404 error.

Did you delete you cache and browsing history for the browser currently using?

Once you done the above two steps. log out of coursera, then re login. then open assignment page at this time, you will probably see the 404 error.

Next click help=== reboot,

Once rebooting is done, click help again and click the Get the latest version, then Update lab.

Voila you will have a fresh updated copy. Share the image of grader cell Triple loss here to confirm it matches with the image I posted.

Regards
DP

I did. But these files will not leave.

not an issue. at this time, do the next steps I mentioned just now. some files don’t get deleted

Phew Okay, now re do the assignment as this is updated version, your old codes won’t work for this assignment :slight_smile:

And all the best as I know the updated ones are lot tougher than the older version especially When tensorflow is misunderstood, right @arvyzukai arvy :wink:

You can disturb @arvy if you are stuck at codes, he is current expert for this updated course.

Regards
DP

1 Like

Hi @arvyzukai the vectors v1 & v2 seem interchanged in the graded assignment as opposed to the vector orders that was mentioned in the excel that you attached Changing the linalg.matmul(v1,2) to linalg.matmul(v2,v1) helped for me

1 Like

@RyeToast, generally you don’t need to delete everything, just the files with .ipynb and .py extensions.

Deleting the sub-folders usually isn’t necessary, because it’s very unlikely there are any problems in the sub-folders.

This assumes you have not modified any of the sub-folder contents.

Hi @Ramkumar_Anantha

Yes, indeed they have been switched in the new version.

Thank you for the correction!

Hi @TMosh

The very unlikely cases are the ones most difficult to catch :slight_smile:

There are rare cases, when the learner overwrites the trained model and try to complete the following exercises based on the wrong model (without retraining, or using cached model, or overwritten the course’s fully trained model).
Or, even tries to “play around” with datasets (for example, when in .csv form) and at the end forgets that (as a possible result, suddenly the accuracy is not right etc. :slight_smile:).

You’re right that most cases are not that peculiar but learner’s imagination has few limits and as a rule of thumb I think it’s better to just start fresh :slight_smile:

Cheers

1 Like

That’s a good idea when nothing else seems to work.

But the time spent searching until one decides that nothing seems to work could be hours or days.
Of course, if the model size or dataset are measured in GBs then unnecessary wasting resources (bandwith) by constantly refreshing everything is also bad.
It’s a balance act :slight_smile:

1 Like

True enough.

Hi @RyeToast

It’s against the rules to post your solution code, so please remove it (including your previous post).

I found my old excel file and updated the calculations (which you can check against yourself by printing them):

So first hint, in this Assignment we dot multiply v2 with v1 (not other way around). This is the choice of course creators - we compare the right hand side questions with left hand side questions (not the other way around; it makes a difference when questions are not duplicates).

Second hint - you deleted some code comments/hints. In particular, for mask_exclude_positives you need:

    # create a composition of two masks: 
    # the first mask to extract the diagonal elements, 
    # the second mask to extract elements in the negative_zero_on_duplicate matrix that are larger than the elements in the diagonal 

you just have one part of it (the first is easier, you can see it in the picture).

Third hint, again, I see you have different code comment, which should have been:

    # add the two losses together and take the `tf.math.reduce_sum` of it

Cheers

2 Likes

Hello, @arvyzukai

I’m currently working on the Triplet Loss function implementation and have encountered some difficulties that I’m hoping to get your insights on.

After incorporating the valuable feedback from the discussion board and the provided Excel example, I revised my TripletLossFn function. However, I’m still facing challenges with the implementation, specifically receiving a NameError in my Jupyter notebook.

Here’s a brief overview of the issue:

  • In my notebook, where I define the vectors v1 and v2 and call TripletLossFn(v1, v2), I’m encountering a NameError: name 'np' is not defined.
  • I have ensured that NumPy is imported in an earlier cell, but the error persists.
  • My Jupyter notebook setup is as follows:
    • Cell 0: Definition of TripletLossFn.
    • Cell 1: Definition of v1 and v2 arrays and calling TripletLossFn.

I am seeking guidance on how to resolve this error and any further advice you might have on the implementation of the Triplet Loss function. Below is the snippet of my current implementation for your reference:

![Screenshot 2024-01-23 at 1.44.49 PM|690x168](upload://nNoS8llwGHJHe7m8iBoX5LMRcEd.png)

Could you please help me understand if there’s something I’m missing in the setup or any other aspect of the implementation? Any additional guidance would be greatly appreciated.

Thank you very much for your time and support.

The error about “np not defined” means you opened the notebook but did not run all of the cells first.

You have to do this every time you open the notebook, so that the workspace is initialized and configured.

1 Like

That worked! Thank you!! :pray:

Hey, Anju_Tyagi

Welcome!

Wanted to let you know (before the moderators slap your wrist) that no posting of code is allowed. Only post the error comment.

Thank you, Rye. I deleted my post and missed the one from @arvyzukai while going through this thread. However, I was able to figure out the issue, and now I am getting correct value

The first hint helped me so much. Thank you!