# RNN Concepts too confusing

**URL:** <https://community.deeplearning.ai/t/rnn-concepts-too-confusing/403097>\
**Category:** NLP with Sequence Models\
**Tags:** week-module-2\
**Created:** [July 31, 2023, 9:30am UTC](https://community.deeplearning.ai/t/rnn-concepts-too-confusing/403097 "2023-07-31T09:30:35Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [July 31, 2023, 10:34am UTC](https://community.deeplearning.ai/t/rnn-concepts-too-confusing/403097/2 "2023-07-31T10:34:56Z")

</div>

> [@Mayank11](#):
>
> a. Is it right to assume that in first time step embedding for “I” will be sent to the model, then in 2nd time step embedding for “am” will be sent and so on till 6th step when embedding for “learning” will be sent to model?

That is correct.

> [@Mayank11](#):
>
> b. Dimension of x should be (batch\_size \* max\_len \* embed\_dim).

Yes, that would be the output of embedding layer and input to the RNN layer. ([More on this](https://community.deeplearning.ai/t/number-of-lstm-units-in-trax/203186/5))

> [@Mayank11](#):
>
> In forward function, for concatenation to work when one element of x is sent to the model, dimension of h\_t should have been (max\_len \* embed\_dim) But dimension of h is (embed\_dim,1). How come?

I’m not sure I fully understand your question. What is the context of this? In other words what are referring here? To be short, for one output you need (embed\_dim, 1), for more outputs you need (embed\_dim, more\_dim), but maybe I do not understand the context here.

> [@Mayank11](#):
>
> a. The ShiftRight layer shifts input to the right by n\_positions which for n\_positions = 1 will shift our input to “0”, “am”, “happy”, “I”, “am”, “learning”. Isn’t this causing the first word (“I” here) to be ignored altogether? What is the purpose of ShiftRight layer?

The purpose of the ShiftRight layer here is to get the targets, so [“I”, “am”, “happy”] would become [“\<sos\>”, “I”, “am”, “happy”]. [Check this post](https://community.deeplearning.ai/t/creating-a-gru-model-using-trax/165167) for more details.

For custom GRU [check this post](https://community.deeplearning.ai/t/coding-concerning-stacking-grus/254975).

> [@Mayank11](#):
>
> The lecture says that deep RNNs are just RNNs stacked on top of each other. The input to next layer RNN is the output / activation of previous layer. Since this happens after 1 time step, does this mean that for a network of k RNNs stacked on top of each other, the earliest we can get an output is after k+1 time step? If so, what use cases can this possibly be used ?

Stacking layers of Recurrent RNNs significantly improve the model’s ability to learn complex sequential patterns and dependencies in sequential data. Deep RNNs can improve generalization by learning a more compact and abstract representation of the data. The lower layers capture the specific details, while the higher layers learn more generalized features that are relevant to the task.  
I’m not sure what you mean by “… the earliest we can get an output is after k+1 time step…”

Cheers

P.S. It is a better practice to ask one question a topic, this way others might find the same question/answers easier. And it also help to drive the conversation better (one answer might change the other question).

---

_[View the full topic](https://community.deeplearning.ai/t/rnn-concepts-too-confusing/403097)._
