C4W1_Assignment Translator function take in decoder or model.decoder

when i use

            next_token, logit, state, done = generate_next_token(
                decoder=model.decoder,
                context=context,
                next_token=next_token,
                done=done,
                state=state,
                temperature=temperature
            )

I pass the test, but it return this problem


but beside that, everything else work fine, but when I use decoder

            next_token, logit, state, done = generate_next_token(
                decoder=decoder,
                context=context,
                next_token=next_token,
                done=done,
                state=state,
                temperature=temperature
            )

that cell run and everything below work fine too, only the

w1_unittest.test_translate(translate, trained_translator)

return fails, why is that

Hi @namgiang,

It’s quite likely that the initialization process for decoder and model.decoder isn’t identical, which would explain the differences in results.

Try debugging your code by printing the shapes and other intermediate values to locate the issue more easily.

Hope this helps! Feel free to ask if you need further assistance.

1 Like

Thank you, @Alireza_Saei, for your response! I just reran the whole notebook, and now everything is okay. The model.coder does not give that error anymore. I guess maybe the server had some problems. Most recent problems I must ask about are from the server as well, so I think it is okay now. I will keep you updated if there is anything wrong.

You’re welcome @namgiang ! Happy to help!

Sometimes all you need to do is to restart the notebbok kernel and run the whole notebbok again (especially if you modify some cells)