C4W3, error in answer_question function

In week 3 of Course 4, for the line

next_word = transformer_utils.next_word(model, padded_question, tokenized_answer)

I’m getting the error to be as:

seq = 1 - tf.cast(tf.math.equal(decoder_token_ids, 0), tf.float32)

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


You got the positional arguments wrong:
# Notice that it expects the question, answer and model (in that order)


1 Like

Thank you so much, it worked!