This question is edited because the mentor says my question violating Code of Conduct
@Alfiki_Diastama_Afan This post contains your solution which is a breach of Code of Conduct. Please take down this post and post a new one inline with COC.
I’m so sorry if my question doesn’t obey the code of conduct. But I cannot delete my question. Can you provide me how to make my question better?
Update: I have solved this problem. And I have edit my question to make sure I don’t share my solution to others.
Thanks for taking it down! To repost it, you can describe the issue by mentioning the graded exercise number and what the error message say.
For future reference, it’s very helpful to include a screen capture image of any error messages or asserts. If this includes a small fragment of your code within the error message, that is OK.
If a mentor needs to see your code, we’ll contact you with instructions.
Hello, I encountered the same error. Even though the notebook shows my code is correct, It shows there was an error grading my submission.
What can be done?
Passing the tests in the notebook does not prove your code is perfect. The grader uses different tests and different conditions.
Note: I’m not a mentor for this course, so I do not have any specific advice.
Hi! was this solved? If not, please share your code with me and describe your situation.
Hello, i’m having the same problem, can someone help me to solve it ?
But the the grading is giving a me a zero !
Can you share a screenshot of your submission grader output which gives information on why you got zero!!!
Couldn’t do a screenshot because the error message was too long but here it is:
There was an error grading your submission. Details:
{{function_node _wrapped__SparseSoftmaxCrossEntropyWithLogits_device/job:localhost/replica:0/task:0/device:CPU:0}} Received a label value of -1 which is outside the valid range of [0, 17). Label values: 9 10 15 15 9 9 9 9 9 9 9 9 9 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [Op:SparseSoftmaxCrossEntropyWithLogits] name:
You can always share error in two separate images, sometimes a complete error detail is required for us to understand what is the issue.
Also confirm, you are doing an updated assignment.
is the grader output where it shows why the grade cell masked_loss failed and not the one you have shared.
Regards
DP
Passing the notebook unit tests does not prove your code is perfect.
The grader:
all the output: There was an error grading your submission. Details:
{{function_node _wrapped__SparseSoftmaxCrossEntropyWithLogits_device/job:localhost/replica:0/task:0/device:CPU:0}} Received a label value of -1 which is outside the valid range of [0, 17). Label values: 9 10 15 15 9 9 9 9 9 9 9 9 9 9 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [Op:SparseSoftmaxCrossEntropyWithLogits] name:
The test cell output:
Yes i’m doing an updated assignment
Please share codes of masked loss via personal DM. Click on my name and then message.
Hello @Burak_Bakkar
Seems like either you are using an obsolete copy to do the assignment. Your grader cells do not match with my updated assignment grader cell. or either you edited the grader cell. By any chance only way around to do the correction, is to get a fresh copy of the assignment and re-do the assignment.
Also make sure write codes only where it is asked to do so, per se Write codes were None is mentioned between ###START AND END CODE HERE####.
Also for calculation loss function, please refer the below link to write the codes correctly, the way you have recalled sparsecategoricalcrossentropy is incorrect.
How to get a fresh copy? refer the below link and follow the steps, make sure you save a copy before.
Regards
DP
Thank you for helping me, i did what you told me to do and i got a fresh copy of the assignment. Yet i still have a problem with the masked_loss function.
I’m pretty much sure that from_logits should be True because y_pred
is a logits tensor.
I’m not sure about the other parameter what should i put, i tried all possibilites. Still don’t get it.
please don’t post codes here, it is against community guidelines. kindly remove or edit the image and share only your output with the expected output on a public post thread.
Hello @Burak_Bakkar
the below instruction should be able to help you to do the correction to the codes
ignore_class
: This indicates which class should be ignored when computing the crossentropy. Remember that the class related to padding value is set to be 0.
Instructions : You will use a tf.keras.losses.SparseCategoricalCrossentropy
object to create a loss function that ignores the padded value related to the label. Remember that for padding you are using the value −1 and not 0, as opposed to the text padding!
Although for the above 1st instruction it mentions padding value is set to 0, you need to change the padding value here to -1 as opposed to the text padding, but you have used it as False causing the error.
Regards
DP
Thanks a lot, there’s no documentation about the ignore_class parameter in tf.keras.losses.SparseCategoricalCrossentropy
That’s why i got really confused, i thought it was a boolean parameter.
Thank you very much !