# C4W2-Assignment Block 1 of DecoderLayer

**URL:** <https://community.deeplearning.ai/t/c4w2-assignment-block-1-of-decoderlayer/797831>\
**Category:** NLP with Attention Models\
**Tags:** week-module-2\
**Created:** [April 8, 2025, 11:31pm UTC](https://community.deeplearning.ai/t/c4w2-assignment-block-1-of-decoderlayer/797831 "2025-04-08T23:31:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shuo21](https://avatars.discourse-cdn.com/v4/letter/s/ec9cab/32.png) [@Shuo21](https://community.deeplearning.ai/u/Shuo21)\
**Post date:** [April 8, 2025, 11:31pm UTC](https://community.deeplearning.ai/t/c4w2-assignment-block-1-of-decoderlayer/797831/1 "2025-04-08T23:31:40Z")

</div>

I have a question regarding the Block 1 of DecoderLayer.

The hint suggested that only the look-ahead mask is needed for block 1 and I did pass all the unit tests by only passing the look-ahead mask.

However, I wonder why the padding mask is not needed in the self-attention layer of a decoder. Isn’t padding mask always needed in order to guarantee that all sequences within a batch have the same length?  
However, when I tried the following code, I got a couple of failed unit tests for test\_transformer.

combined\_mask = tf.maximum(padding\_mask, look\_ahead\_mask[:, tf.newaxis, :])  
mult\_attn\_out1, attn\_weights\_block1 = self.mha1(x, x, x, combined\_mask, return\_attention\_scores=True)

---

<div class="post-metadata">

**Author:** ![Deepti\_Prasad](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/deepti_prasad/32/165831_2.png) [@Deepti\_Prasad](https://community.deeplearning.ai/u/Deepti_Prasad)\
**Post date:** [April 9, 2025, 9:01am UTC](https://community.deeplearning.ai/t/c4w2-assignment-block-1-of-decoderlayer/797831/2 "2025-04-09T09:01:15Z")

</div>

don’t use any hard code method of merging masking.

the reason block1 uses only look ahead mask is to make neural network to ignore the future values on the decoder input(target input).

Kindly share screenshot of the failed test without sharing any part of grade function codes.
