# C4\_W4\_Assignment

**URL:** <https://community.deeplearning.ai/t/c4-w4-assignment/350136>\
**Category:** NLP with Attention Models\
**Tags:** week-module-4\
**Created:** [June 4, 2023, 4:44pm UTC](https://community.deeplearning.ai/t/c4-w4-assignment/350136 "2023-06-04T16:44:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![muxin](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@muxin](https://community.deeplearning.ai/u/muxin)\
**Post date:** [June 4, 2023, 4:44pm UTC](https://community.deeplearning.ai/t/c4-w4-assignment/350136/1 "2023-06-04T16:44:22Z")

</div>

Please help, I am getting the error below when I was doing NLP specialization C4\_W4 Assignment Chatbot.

 ![image](https://global.discourse-cdn.com/dlai/original/3X/4/6/46a0a4b063d761a77037286322612e55538dde85.png)

My source code is shared here  
def ReformerLM(vocab\_size=33000, n\_layers=2, mode=‘train’, attention\_type=tl.SelfAttention):  
“”"  
Args:  
vocab\_size (int): size of the vocabulary  
n\_layers (int): number of decoder layers  
mode (string): setting of the model which can be ‘train’, ‘eval’, or ‘predict’  
attention\_type(class): attention class to use  
Returns:  
model (ReformerLM): a reformer language model implemented in Trax  
“”"

```
### START CODE HERE (REPLACE INSTANCES OF 'None' WITH YOUR CODE) ###
# initialize an instance of Trax's ReformerLM class
model = tl.Serial( 
            trax.models.reformer.ReformerLM( 
            # set vocab size
            vocab_size = vocab_size,
            # set number of layers
            n_layers = n_layers,
            # set mode
            mode = mode,
            # set attention type
            attention_type=attention_type
        )
        , tl.LogSoftmax() 
    )        
### END CODE HERE ###
return model # tl.Serial(model, tl.LogSoftmax(),)

```

---

<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:** [June 5, 2023, 6:29am UTC](https://community.deeplearning.ai/t/c4-w4-assignment/350136/2 "2023-06-05T06:29:24Z")

</div>

Hi @muxin

That is a strange error. What notebook you were working on (local or coursera)? Did you pass the `mode` (in a `temp_model = ...` line) parameter since it’s not in the assignment?

---

<div class="post-metadata">

**Author:** ![ai\_curious](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/ai_curious/32/128003_2.png) [@ai\_curious](https://community.deeplearning.ai/u/ai_curious)\
**Post date:** [June 5, 2023, 8:37am UTC](https://community.deeplearning.ai/t/c4-w4-assignment/350136/3 "2023-06-05T08:37:07Z")

</div>

> [@arvyzukai](#):
>
> local or coursera

I wondered the same thing, especially with _conda_ in the exception path. I also am curious about the package structure since the on-line doc

> **[trax.layers.core. - trax.layers — Trax documentation](https://trax-ml.readthedocs.io/en/latest/trax.layers.html#module-trax.layers.core)**
>
> Modifications to data and computation to use accelerators (better).

has _trax.layers.core.Dense_ and not _trax.layers.Dense_. Unfortunately I can neither install locally on my Mac OS nor see the exercise source to dig deeper.

---

<div class="post-metadata">

**Author:** ![muxin](https://avatars.discourse-cdn.com/v4/letter/m/3ec8ea/32.png) [@muxin](https://community.deeplearning.ai/u/muxin)\
**Post date:** [June 5, 2023, 11:45am UTC](https://community.deeplearning.ai/t/c4-w4-assignment/350136/4 "2023-06-05T11:45:43Z")

</div>

I was working on cousera.

---

<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:** [June 5, 2023, 2:18pm UTC](https://community.deeplearning.ai/t/c4-w4-assignment/350136/5 "2023-06-05T14:18:57Z")

</div>

I sent you a personal message. Please respond when you have time.

---

<div class="post-metadata">

**Author:** ![Raffay\_Rana](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@Raffay\_Rana](https://community.deeplearning.ai/u/Raffay_Rana)\
**Post date:** [July 23, 2023, 11:32am UTC](https://community.deeplearning.ai/t/c4-w4-assignment/350136/6 "2023-07-23T11:32:28Z")

</div>

I’m having the same issue. Any help would be appreciated
