C4W2_Assignment 2: Transformer Summarizer InvalidArgumentError

Hi,

When I summarize a sentence, I get the bellow error.

InvalidArgumentError: Exception encountered when calling layer ‘encoder_14’ (type Encoder).

{{function_node _wrapped__AddV2_device/job:localhost/replica:0/task:0/device:GPU:0}} required broadcastable shapes [Op:AddV2] name:

Call arguments received by layer ‘encoder_14’ (type Encoder):
• x=tf.Tensor(shape=(1, 150), dtype=int32)
• training=False
• mask=tf.Tensor(shape=(1, 1, 150), dtype=float32)

Hi @sk_369

One of your function code related to encoder has been recalled with an incorrect argument.

Send screenshot of grade cell for which you failed the test by personal DM.

Also probably there are similar threads for the grade cell you are encountering issue, so use search tool with the error you got and go through those thread comments which might provide you hints in debugging your codes.

Otherwise, you send the codes by personal DM. Click on my name and then message.

Regards
DP

Sent u the details at by personal DM.

please check your DM

hI @sk_369

1.in scaled dot product grade cell, you don’t require to apply axis when you are calculating attention weights, kindly remove axis=-1

2.your decoder layer codes are incorrect.

2 a. for block 1 codes
Block 1 is a multi-head attention layer with a residual connection, and look-ahead mask. Like in the EncoderLayer, Dropout is defined within the multi-head attention layer.
As the block 1 has 3 multi layer, you require to pass the self.mha1 to 3 linear layer recalled for class DecodeLayer i.e x, x, x with correct mask(which you already used here)

2 b. You are not suppose to apply training to the self attention blocks codes, training is only applied to the dropout ffn_output. Read instructions carefully to avoid such error.

Also refer the below thread for detail instructions for grade cell 2 mistakes

Do these corrections and let me know in DM, how you correction. Then we will move to next grade cell.

Regards
DP