# C5\_W4\_A1\_Transformer\_Subclass\_v1 DecoderLayer Class why not "use\_causal\_mask"

**URL:** <https://community.deeplearning.ai/t/c5-w4-a1-transformer-subclass-v1-decoderlayer-class-why-not-use-causal-mask/664836>\
**Category:** Sequence Models\
**Tags:** week-module-4, coursera-platform\
**Created:** [July 18, 2024, 1:01am UTC](https://community.deeplearning.ai/t/c5-w4-a1-transformer-subclass-v1-decoderlayer-class-why-not-use-causal-mask/664836 "2024-07-18T01:01:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maggie\_Zhang3](https://avatars.discourse-cdn.com/v4/letter/m/3da27b/32.png) [@Maggie\_Zhang3](https://community.deeplearning.ai/u/Maggie_Zhang3)\
**Post date:** [July 18, 2024, 1:01am UTC](https://community.deeplearning.ai/t/c5-w4-a1-transformer-subclass-v1-decoderlayer-class-why-not-use-causal-mask/664836/1 "2024-07-18T01:01:40Z")

</div>

In DecoderLayer class excercise, when calculating mult\_attn\_out1, attn\_weights\_block1, why not seeing “use\_causal\_mask=True” in the call argument for look ahead mask?

---

<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:** [July 18, 2024, 6:42am UTC](https://community.deeplearning.ai/t/c5-w4-a1-transformer-subclass-v1-decoderlayer-class-why-not-use-causal-mask/664836/2 "2024-07-18T06:42:38Z")

</div>

Hi @Maggie_Zhang3

**use\_causal\_mask** : A boolean to indicate whether to apply a causal mask to prevent tokens from attending to future tokens

if you check the decoder layer call function, one of the argument mentions  
look\_ahead\_mask – Boolean mask for the target\_input

A look-ahead mask is required to prevent the decoder from attending to succeeding words, such that the prediction for a particular word can only depend on known outputs for the words that come before it.

So as we are using look\_ahead\_mask to the attention block1, use\_casual\_mask=True is not required to be used here.
