# C3W1\_RNNs How exactly are the GRU layers connected to each other

**URL:** <https://community.deeplearning.ai/t/c3w1-rnns-how-exactly-are-the-gru-layers-connected-to-each-other/604034>\
**Category:** NLP with Sequence Models\
**Tags:** week-module-1\
**Created:** [April 3, 2024, 9:16pm UTC](https://community.deeplearning.ai/t/c3w1-rnns-how-exactly-are-the-gru-layers-connected-to-each-other/604034 "2024-04-03T21:16:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharthak\_Ghosh](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Sharthak\_Ghosh](https://community.deeplearning.ai/u/Sharthak_Ghosh)\
**Post date:** [April 3, 2024, 9:16pm UTC](https://community.deeplearning.ai/t/c3w1-rnns-how-exactly-are-the-gru-layers-connected-to-each-other/604034/1 "2024-04-03T21:16:47Z")

</div>

```auto
model_GRU = tf.keras.Sequential([
    tf.keras.layers.GRU(256, return_sequences=True, name='GRU_1_returns_seq'),
    tf.keras.layers.GRU(128, return_sequences=True, name='GRU_2_returns_seq'),
    tf.keras.layers.GRU(64, name='GRU_3_returns_last_only'),
    tf.keras.layers.Dense(10)
])

```

From the code snippet above, how exactly are the layers connected to each other? How are the 256 hidden states mapped to 128 inputs?

---

<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:** [April 4, 2024, 5:32am UTC](https://community.deeplearning.ai/t/c3w1-rnns-how-exactly-are-the-gru-layers-connected-to-each-other/604034/2 "2024-04-04T05:32:35Z")

</div>

The sequential type of model gets an input and runs it through all the layers inside it in a sequence. Input here is going through from 256 GRU cells to final output which has 10 neurons and there are other layers in between!

---

<div class="post-metadata">

**Author:** ![Sharthak\_Ghosh](https://avatars.discourse-cdn.com/v4/letter/s/e495f1/32.png) [@Sharthak\_Ghosh](https://community.deeplearning.ai/u/Sharthak_Ghosh)\
**Post date:** [April 4, 2024, 2:47pm UTC](https://community.deeplearning.ai/t/c3w1-rnns-how-exactly-are-the-gru-layers-connected-to-each-other/604034/3 "2024-04-04T14:47:32Z")

</div>

What you have mentioned is something I can already infer from code. Could you help me visualize the RNN unfolding and the inputs in a distinct way? Also why is Layer and Layer 2 fully connected?  
The gap that I am trying to understand is in the lecture Yones talks about input at various timesteps and the hidden state that gets propagated. How is that represented in the above configuration?

---

<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:** [April 5, 2024, 6:08am UTC](https://community.deeplearning.ai/t/c3w1-rnns-how-exactly-are-the-gru-layers-connected-to-each-other/604034/4 "2024-04-05T06:08:35Z")

</div>

No, I cannot create new material for you, no time for that, but I advise you to check the Deep Learning Specialization, thats where I learned it from!
