C4W2_Assignment Exercise 3 Decoder

I am working on C4W2_Assignment, for Exercise 3: Decoder: I am not sure how to implement:


pass x and the encoder output through a stack of decoder layers and save the attention weights

        # of block 1 and 2 (~1 line)
        x, block1, block2 = 

As far as I understand, I need
x, block1, block2 = DecoderLayer(x)
Is it right ?

Update: I use as:
x, block1, block2 = self.dec_layers(x, enc_output, training, look_ahead_mask, padding_mask, return_attention_scores=True)

But the test has errors such as:


Cell In[32], line 68, in Decoder.call(self, x, enc_output, training, look_ahead_mask, padding_mask)
64 # use a for loop to pass x through a stack of decoder layers and update attention_weights (~4 lines total)
65 for i in range(self.num_layers):
66 # pass x and the encoder output through a stack of decoder layers and save the attention weights
67 # of block 1 and 2 (~1 line)
—> 68 x, block1, block2 = self.dec_layers(x, enc_output, training, look_ahead_mask, padding_mask, return_attention_scores=True)
70 #update attention_weights dictionary with the attention weights of block 1 and block 2
71 attention_weights[‘decoder_layer{}_block1_self_att’.format(i+1)] = block1

TypeError: Exception encountered when calling layer ‘decoder’ (type Decoder).

‘ListWrapper’ object is not callable


I suspect the input parameters were not correct.

Never mind, solved

Hey, is your call to self.dec_layers correct? I am wrestling with an error there too, albeit different from yours and wondering if I am passing the right input.