C4W3_Assignment - TypeError

Hi,

Getting bellow error while testing the model.

TypeError: in user code:

File "/tf/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 0x7f3ce95c69d0> to Tensor. Consider casting elements to a supported type. See https://www.tensorflow.org/api_docs/python/tf/dtypes for supported TF dtypes.

Hi @sk_369

A detailed post with error encountered with which grade cell and how you have recalled the codes without mentioning directly the codes would benefit you more from getting faster response.

According rather than copy pasting the errors, click a screenshot which will capture the issue in toto.

When you have lengthy error, you can always click two different sections of the error.

So kindly provide details about which grade cell you encountered this issue as the error indicated.

Also when I just copy pasted your error on the search tool, I got a similar thread, so I advise you to use it search similar error assignment threads which previously learners must have encountered. Referring them sometimes helps you debugging.

Regards
DP

My previous tagged comment link should help you resolve your issue. check the last comment in that thread, cross check your next word codes.

You recalling with incorrect arguments assigned for that grade cell, using global variable can throw error.

Also you do not require again to apply the padding mask, as the model argument for that cell mentions it is already padded.

So next word require you to use the correct call arguments for input, output and model, also in the correct sequence.

you cant feed first model and then input and output.

For answer question grade cell, input is recalled as tokenized question and output as tokenized answer

Regards
DP

I resolved the issue after going through the thread u provided.

Now the test case is failing with bellow error.

@sk_369

i just noticed your next code in the error, perhaps you haven’t still didn’t change the output while predicting next word?

Remember output is not recalled argument for answer question grade cell.

Your last code line also needs correction.
remember the instruction mentions to stop prediction next word once it reaches decode maxlen.

Sent.

hi @sk_369

I noticed one of the code line is completely missing in your code, so by any chance you deleted the code after we are suppose to add dimension, which creates id for end of sequence eos.

This code line is not present in your code cell :point_down:t2:
Get the id of the EOS token

or probably you are using an obselete copy, in any case, please get a fresh copy and re-do the assignment as you might fail the grader if you are working on an old copy or edited out cell.

Regards
DP