Transformer Utils from Grader

Hi. I’m getting this error from the grader in the last graded function of the specialization in NLP: There was an error grading your submission. Details:
in user code:

File "/grader/transformer_utils.py", line 547, in create_padding_mask  *
    seq = 1 - tf.cast(tf.math.equal(decoder_token_ids, 0), tf.float32)

TypeError: Failed to convert elements of <transformer_utils.Transformer object at 0x7f4053ae7ac0> to Tensor. Consider casting elements to a supported type. See https://www.tensorflow.org/api_docs/python/tf/dtypes for supported TF dtypes.

@MarcoGam2410

Kindly share screenshot of complete error and also avoid copy pasting information as screenshot gives better understanding of your code error or codes.

Please only post error screenshot here. if I require to see code, will ask you.

Off course

can you share a screenshot of unittest cell output for your answer question grade function?

did you pass the unittest cell for that grade function.

Remember unittest cells are the next cell after grade function which check your grade function code execution and gives an error output if your grade function had an incorrect code.

Don’t post any codes screenshot here. Only output of unittest cell for answer question grade function.

Hi. No, it doesn’t pass the test, but, after debugging, the problem lies on the transformer_utils grader function.

yes I know you didn’t pass the test, what output it showed or gave error, take a screenshot without sharing any part of grade function cell and post it here.

if you didn’t pass test cell, why are you submitting assignment for grading?

This error with transformer_utils also happen on a not graded part, related to where the second graded function is called. That said, this is an issue with the transformer_utils grader function. I realised when I refresh the notebook sometimes the error disappears

  • This is the part I’m refeering to, so please consider giving a look at the grader function

It seems there is an error in your code. That’s what you seem to be describing.

Maybe you misunderstood. What I meant to say is thatwhenever the transformer_utils function (that is inside the grader folder) (so the transformer_utils that is given to us) is called, the error appears. This seems to be going nowhere. Please fix this issue asap.

share the complete error screenshot.

Also remember this issue is not by deep learning.ai but because of your incorrect coding.

Also remember mentors are doing volunteer work and demanding to resolve issue asap, doesn’t go well with community guidelines.

Being hurry, not clearing unittest and yet submitting for assignment grading caused such issue where learning becomes less of priority than clearing assignment.

You need to share first screenshot of the unittest cell you didn’t pass, then share this second error you got, but share complete error log.

My coding is not incorrect. I refreshed the page and now it works. If you don’t know what you’re talking about, please do not comment just that I didn’t pass because that helps no one. Hope it helps


Just finished the specialization. Thank you for your time.

1 Like

we are not intuitor to know if there was a problem related to coursera environment until we see the complete error.

Try to post your query in better way from next time.

Good to know your issue was resolved.

As far as I know if coursera environment issue happens the error usually comes as grader error, file was corrupted.

I have never seen a type error and the error screenshot you shared, tells your sequence to predict the next word was not in correct sentence perse it needed to be question, answer and then model but I didn’t mention because I wanted to see the complete error first.

I am not assuming that your were incorrect, there are similar threads already who have encountered the same error, you can search in discourse community.