# Error in the encoder layer

**URL:** <https://community.deeplearning.ai/t/error-in-the-encoder-layer/47876>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [October 9, 2021, 8:11pm UTC](https://community.deeplearning.ai/t/error-in-the-encoder-layer/47876 "2021-10-09T20:11:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edu4rd](https://avatars.discourse-cdn.com/v4/letter/e/a698b9/32.png) [@Edu4rd](https://community.deeplearning.ai/u/Edu4rd)\
**Post date:** [October 9, 2021, 8:11pm UTC](https://community.deeplearning.ai/t/error-in-the-encoder-layer/47876/1 "2021-10-09T20:11:47Z")

</div>

Hi,  
can you help me to see why my call is wrong?  
Looking at the error message the problem seems to be in my call to the fully connected layer but I can’t see what’s wrong. It seems quite straight forward:

```
    ffn_output = self.fnn(out1) # (batch_size, input_seq_len, fully_connected_dim)

```

Here is the error log:

# UNIT TEST

## EncoderLayer\_test(EncoderLayer)

AttributeError Traceback (most recent call last)  
 in   
1 # UNIT TEST  
----\> 2 EncoderLayer\_test(EncoderLayer)

~/work/W4A1/public\_tests.py in EncoderLayer\_test(target)  
84 encoder\_layer1 = target(4, 2, 8)  
85 tf.random.set\_seed(10)  
—\> 86 encoded = encoder\_layer1(q, True, np.array([[1, 0, 1]]))  
87  
88 assert tf.is\_tensor(encoded), “Wrong type. Output must be a tensor”

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base\_layer.py in **call** (self, \*args, \*\*kwargs)  
1010 with autocast\_variable.enable\_auto\_cast\_variables(  
1011 self.\_compute\_dtype\_object):  
 → 1012 outputs = call\_fn(inputs, \*args, \*\*kwargs)  
1013  
1014 if self.\_activity\_regularizer:

in call(self, x, training, mask)  
46  
47 # pass the output of the multi-head attention layer through a ffn (~1 line)  
—\> 48 ffn\_output = self.fnn(out1) # (batch\_size, input\_seq\_len, fully\_connected\_dim)  
49  
50 # apply dropout layer to ffn output during training (~1 line)

AttributeError: ‘EncoderLayer’ object has no attribute ‘fnn’

---

<div class="post-metadata">

**Author:** ![edwardyu](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/edwardyu/32/82_2.png) [@edwardyu](https://community.deeplearning.ai/u/edwardyu)\
**Post date:** [October 11, 2021, 12:21am UTC](https://community.deeplearning.ai/t/error-in-the-encoder-layer/47876/2 "2021-10-11T00:21:24Z")

</div>

Hi @Edu4rd ,

It’s `self.ffn` rather than `self.fnn`.  
 ![image](https://global.discourse-cdn.com/dlai/original/2X/1/113c6c57fe70a22b60e1557294fe04ee7136fa42.png)
