Uable to pass w1_unittest.test_decoder(Decoder, CrossAttention)

->Decoder class

{moderator edit - solution code removed}

Implementation check:-

Do a quick check of your implementation

Create an instance of your class

decoder = Decoder(VOCAB_SIZE, UNITS)

Notice that you don’t need the embedded version of sr_translation since this is done inside the class

logits = decoder(encoder_output, sr_translation)

print(f’Tensor of contexts has shape: {encoder_output.shape}‘)
print(f’Tensor of right-shifted translations has shape: {sr_translation.shape}’)
print(f’Tensor of logits has shape: {logits.shape}')

output:-
Tensor of contexts has shape: (64, 14, 256)
Tensor of right-shifted translations has shape: (64, 15)
Tensor of logits has shape: (64, 15, 12000)

Expected Output
Tensor of contexts has shape: (64, 14, 256)
Tensor of right-shifted translations has shape: (64, 15)
Tensor of logits has shape: (64, 15, 12000)

Expected output is matching with output but still
w1_unittest.test_decoder(Decoder, CrossAttention)

says:-
Failed test case: Incorrect third dimension of decoder output.
Expected: 6
Got: 12000

Also all test passed for w1_unittest.test_cross_attention(CrossAttention)

Hello @Vishwam_Gupta !

In the __init__ method of the Decoder class, ensure that you’re using the local arguments (vocab_size, units) rather than the corresponding global versions (VOCAB_SIZE, UNITS). This will fix the error you are getting.

Just in case you weren’t aware, it’s a common convention to use uppercase letters for global variables (variables used outside of functions and classes and that are supposed to be accessible from anywhere in the program/script), whereas arguments/variables used inside of classes and functions will be lowercase.

Please, add “C4W1, Assignment…” in the title of the post and hide your code, posting solution code does not comply with the code of conduct.