NMT with attention : Failed test case: w1_unittest.test_encoder(Encoder)

Appreciate the help in solving the problem.
Failed test case: Incorrect third dimension of encoder output.
Expected: [32, 64, 256, 512]
Got: 256

Even the previous output was matched with expected output

hi @Sharanjit

There was one more test cell before the unittest 1 test cell, did you get output as expected output?

Yes. now i rectified and got correct solution.
w1_unittest.test_encoder(Encoder): passed this test

Thanks for replying back. Will be in touch if face any further error

1 Like

I saw your other post where you had incomplete codes to the bidirectional layer.

Great you could debug yourself.

one more extra hint, just be careful when you write codes global variables are usually avoided as each grade cells comes with its own local variables(arguments)

Keep Learning!!!

Regards
DP

in # GRADED CLASS: Decoder: In def call(self, context, target, state=None, return_state=False

Pass in the state to the LSTM (needed for inference)
codes removed as posting any part of grade cell codes correct or incorrect is against community guidelines)

Error encountered:
‘bool’ object has no attribute ‘shape’

Pls help in solving this error or should i create a new post?

@Sharanjit

Rather than posting codes, post screenshot of the error you are encountering. It provides information on why and where the codes might have gone incorrect.

Thanks for replying back

PFA here the screenshot

You using incorrect input for def call decoder code for the embedding layer, you cannot use context for both encoder as well as decoder.

Also notice the target argument mentions the right side shifted translation which the assignment instructions given before the grade cel decoder mentions clearly.

Also for the lstm layer, you are suppose to use state argument which is the assigned hidden state of the pre-attention lstm.

Try to re-read instructions carefully and then match with each code you are writing in case you encounter any error. Instructions are given in the grade cell as well as before the grade cells which help you to correlate the task between instructions given in the grade cell and use the arguments correctly.

Adding to @Deepti_Prasad 's inputs, please don’t edit sections of code you’re not instructed to edit. The stack trace point you to these lines:

  • decoder() - check if you passed the correct inputs
  • Decoder class → pre_attention_rnn - based on the instructions if there were cells to edit, make sure your implementation is correct; usually there will be unit tests to make sure your changes are valid

Thanks for suggestions