# C4W2 cannot graded

**URL:** <https://community.deeplearning.ai/t/c4w2-cannot-graded/543079>\
**Category:** NLP with Attention Models\
**Tags:** week-module-2\
**Created:** [January 13, 2024, 5:24am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079 "2024-01-13T05:24:13Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![H\_ng\_Nguy\_n\_Qu\_c](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@H\_ng\_Nguy\_n\_Qu\_c](https://community.deeplearning.ai/u/H_ng_Nguy_n_Qu_c)\
**Post date:** [January 13, 2024, 5:24am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/1 "2024-01-13T05:24:13Z")

</div>

I have problem with submittion although i follow the hint  
There was a problem compiling the code from your notebook. Details:  
Exception encountered when calling layer ‘softmax\_3’ (type Softmax).

{{function\_node \__wrapped\_\_AddV2\_device_/job:localhost/replica:0/task:0/device:CPU:0}} Incompatible shapes: [1,2,2,150] vs. [1,1,1,2] [Op:AddV2] name:

Call arguments received by layer ‘softmax\_3’ (type Softmax):  
• inputs=tf.Tensor(shape=(1, 2, 2, 150), dtype=float32)  
• mask=tf.Tensor(shape=(1, 1, 1, 2), dtype=float32)

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [January 13, 2024, 7:03am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/2 "2024-01-13T07:03:48Z")

</div>

Do you know the posting rules, you are not supposed to publish code solutions!

At attention\_weights try without the axis parameter!

---

<div class="post-metadata">

**Author:** ![H\_ng\_Nguy\_n\_Qu\_c](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@H\_ng\_Nguy\_n\_Qu\_c](https://community.deeplearning.ai/u/H_ng_Nguy_n_Qu_c)\
**Post date:** [January 13, 2024, 7:09am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/3 "2024-01-13T07:09:32Z")

</div>

Thank you and sorry. I read a lot of posts having the same problem, but nobody did not know what is error without code  
Cheers

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [January 13, 2024, 7:11am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/4 "2024-01-13T07:11:12Z")

</div>

Yes next time ask them to send it in private!

---

<div class="post-metadata">

**Author:** ![H\_ng\_Nguy\_n\_Qu\_c](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@H\_ng\_Nguy\_n\_Qu\_c](https://community.deeplearning.ai/u/H_ng_Nguy_n_Qu_c)\
**Post date:** [January 13, 2024, 7:18am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/5 "2024-01-13T07:18:20Z")

</div>

But i still not works ☹

---

<div class="post-metadata">

**Author:** ![H\_ng\_Nguy\_n\_Qu\_c](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@H\_ng\_Nguy\_n\_Qu\_c](https://community.deeplearning.ai/u/H_ng_Nguy_n_Qu_c)\
**Post date:** [January 13, 2024, 7:19am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/6 "2024-01-13T07:19:07Z")

</div>

I have fixed like you suggest but it still not works

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [January 13, 2024, 7:22am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/7 "2024-01-13T07:22:51Z")

</div>

Send me the entire notebook in private let me have a look in it…

---

<div class="post-metadata">

**Author:** ![H\_ng\_Nguy\_n\_Qu\_c](https://avatars.discourse-cdn.com/v4/letter/h/a698b9/32.png) [@H\_ng\_Nguy\_n\_Qu\_c](https://community.deeplearning.ai/u/H_ng_Nguy_n_Qu_c)\
**Post date:** [January 14, 2024, 9:44am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/8 "2024-01-14T09:44:45Z")

</div>

Had anybody done this assignment ☹ I didn’t know how to fix

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [January 15, 2024, 6:12am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/9 "2024-01-15T06:12:30Z")

</div>

Try maybe reseting the notebook and redo the entire assignment, sometimes the problems are found going through it again. But keep your current solutions so you can reuse them!

---

<div class="post-metadata">

**Author:** ![arvyzukai](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/arvyzukai/32/165165_2.png) [@arvyzukai](https://community.deeplearning.ai/u/arvyzukai)\
**Post date:** [January 15, 2024, 8:44am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/10 "2024-01-15T08:44:17Z")

</div>

For future learners - the OP’s mistake was in defining the `dec_padding_mask`.

Note, that when creating padding mask for the decoder’s second attention block - we use the `encoder_input`. In other words, we inform the decoder to not pay attention to padding tokens of the document to be summarized.

Also note, that this is different from `look_ahead_mask` (causal mask) where decoder is only allowed to pay attention to itself and its previous tokens.

Cheers

---

<div class="post-metadata">

**Author:** ![Muhammad\_Hamza9](https://avatars.discourse-cdn.com/v4/letter/m/85f322/32.png) [@Muhammad\_Hamza9](https://community.deeplearning.ai/u/Muhammad_Hamza9)\
**Post date:** [January 30, 2024, 12:36pm UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/11 "2024-01-30T12:36:54Z")

</div>

Thank you so much I was getting the same error solved

---

<div class="post-metadata">

**Author:** ![Cawnpore\_Charlie](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@Cawnpore\_Charlie](https://community.deeplearning.ai/u/Cawnpore_Charlie)\
**Post date:** [April 28, 2024, 7:37pm UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/12 "2024-04-28T19:37:16Z")

</div>

re: " when creating padding mask for the decoder’s second attention block - we use the `encoder_input`"

Then in the Transformer class definition in the notebook is the following comment incorrect?

call(self, input\_sentence, output\_sentence, training, enc\_padding\_mask, look\_ahead\_mask, dec\_padding\_mask):  
“”"  
Forward pass for the entire Transformer  
Arguments:  
input\_sentence (tf.Tensor): Tensor of shape …

```
       dec_padding_mask (tf.Tensor): Boolean mask for the second multihead attention layer

```

The comment says that we should use dec\_padding\_mask for the second mha layer but in reality we should be using the enc\_padding\_mask - am I understanding you correctly?

Thank you.

---

<div class="post-metadata">

**Author:** ![paulinpaloalto](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/paulinpaloalto/32/187_2.png) [@paulinpaloalto](https://community.deeplearning.ai/u/paulinpaloalto)\
**Post date:** [April 28, 2024, 9:41pm UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/13 "2024-04-28T21:41:09Z")

</div>

I don’t know if you are asking about the same chunk of code, but if so I don’t think your interpretation is correct. I believe that the previous hint that Arvydas is giving there is referring to the `next_word` function. In that logic you create the `dec_padding_mask` by calling the `create_padding_mask` function. And the question is what argument you pass to that function in order to achieve that correctly. At least that’s my reading of it.

---

<div class="post-metadata">

**Author:** ![Cawnpore\_Charlie](https://avatars.discourse-cdn.com/v4/letter/c/8baadc/32.png) [@Cawnpore\_Charlie](https://community.deeplearning.ai/u/Cawnpore_Charlie)\
**Post date:** [April 29, 2024, 12:41am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/14 "2024-04-29T00:41:29Z")

</div>

Thank you for the prompt reply.

I think I finally get it. In the Transformer Class definition stage it is referred to as the dec\_padding\_mask for generality as it is intended for use in the 2nd attention layer in the decoder but in the model call in the next\_word function this parameter needs to be based on the encoder input.

I hope I am getting it right.

Thank you.

---

<div class="post-metadata">

**Author:** ![PhucDo22](https://avatars.discourse-cdn.com/v4/letter/p/a698b9/32.png) [@PhucDo22](https://community.deeplearning.ai/u/PhucDo22)\
**Post date:** [October 29, 2024, 9:43am UTC](https://community.deeplearning.ai/t/c4w2-cannot-graded/543079/15 "2024-10-29T09:43:02Z")

</div>

thank you, it actually works. I’ve been tried to fix it :((
