# Week 1 Coding Assignment 2

**URL:** <https://community.deeplearning.ai/t/week-1-coding-assignment-2/414427>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [August 11, 2023, 1:38am UTC](https://community.deeplearning.ai/t/week-1-coding-assignment-2/414427 "2023-08-11T01:38:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjc](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sjc](https://community.deeplearning.ai/u/sjc)\
**Post date:** [August 11, 2023, 1:38am UTC](https://community.deeplearning.ai/t/week-1-coding-assignment-2/414427/1 "2023-08-11T01:38:01Z")

</div>

Hi guys, I am working on the week 1 dinosaur name generator assignment and I am having trouble grasping how the network is learning anything with the training examples that we create during the assignment, here is an example of one:

single\_example\_chars [‘t’, ‘u’, ‘r’, ‘i’, ‘a’, ‘s’, ‘a’, ‘u’, ‘r’, ‘u’, ‘s’]  
single\_example\_ix [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]  
X = [None, 20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19]  
Y = [20, 21, 18, 9, 1, 19, 1, 21, 18, 21, 19, 0

If the input sequence X and target sequence Y are the same then how is the network learning anything?

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 11, 2023, 10:27am UTC](https://community.deeplearning.ai/t/week-1-coding-assignment-2/414427/2 "2023-08-11T10:27:10Z")

</div>

Does this text from the notebook help?

- At each time-step, the RNN tries to predict what the next character is, given the previous characters.
- \mathbf{X} = (x^{\langle 1 \rangle}, x^{\langle 2 \rangle}, ..., x^{\langle T\_x \rangle}) is a list of characters from the training set.
- \mathbf{Y} = (y^{\langle 1 \rangle}, y^{\langle 2 \rangle}, ..., y^{\langle T\_x \rangle}) is the same list of characters but shifted one character forward.
- At every time-step t, y^{\langle t \rangle} = x^{\langle t+1 \rangle}. The prediction at time t is the same as the input at time t + 1.

---

<div class="post-metadata">

**Author:** ![sjc](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sjc](https://community.deeplearning.ai/u/sjc)\
**Post date:** [August 11, 2023, 4:39pm UTC](https://community.deeplearning.ai/t/week-1-coding-assignment-2/414427/3 "2023-08-11T16:39:10Z")

</div>

I think it does, so if I am understanding correctly, for the second pair of numbers in the sequence, the network is mapping how to get 21 when 20 is the “x” input, simultaneously taking the “a” input into account from the previous cell.

---

<div class="post-metadata">

**Author:** ![balaji.ambresh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/balaji.ambresh/32/128697_2.png) [@balaji.ambresh](https://community.deeplearning.ai/u/balaji.ambresh)\
**Post date:** [August 12, 2023, 3:31am UTC](https://community.deeplearning.ai/t/week-1-coding-assignment-2/414427/4 "2023-08-12T03:31:50Z")

</div>

Your understanding is correct.  
RNN aims to predict character at time `t + 1` when X represents character at time `t` and the hidden state represents an encoding of the data seen till time `t - 1`.

---

<div class="post-metadata">

**Author:** ![sjc](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@sjc](https://community.deeplearning.ai/u/sjc)\
**Post date:** [August 12, 2023, 8:52pm UTC](https://community.deeplearning.ai/t/week-1-coding-assignment-2/414427/5 "2023-08-12T20:52:08Z")

</div>

thank you!
