# DLS Course 5, Week 1, assignment 3,

**URL:** <https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [May 3, 2021, 8:17pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054 "2021-05-03T20:17:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![psn](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@psn](https://community.deeplearning.ai/u/psn)\
**Post date:** [May 3, 2021, 8:17pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/1 "2021-05-03T20:17:30Z")

</div>

Hello,

After running the unit test of the djmodel, I get the following error message:

Test failed  
Expected value

[‘Reshape’, (None, 1, 90), 0]

does not match the input value:

[‘TensorFlowOpLayer’, [(None, 90)], 0]

Even though the following code in the djmodel function gives the correct shapes:  
x = X[:,0,:]  
print(x.shape)  
(None, 90)  
x = reshaper(x)  
(None, 1, 90)

please advise.

Thank you  
print(x.shape)

---

<div class="post-metadata">

**Author:** ![psn](https://avatars.discourse-cdn.com/v4/letter/p/9d8465/32.png) [@psn](https://community.deeplearning.ai/u/psn)\
**Post date:** [May 3, 2021, 8:32pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/2 "2021-05-03T20:32:55Z")

</div>

please ignore. problem fixed

---

<div class="post-metadata">

**Author:** ![arosacastillo](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/arosacastillo/32/159244_2.png) [@arosacastillo](https://community.deeplearning.ai/u/arosacastillo)\
**Post date:** [May 3, 2021, 8:34pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/3 "2021-05-03T20:34:44Z")

</div>

Hi,  
Glad that you solved the issue. Maybe it would be great if you share the error and the fix in case other students face the same issue 🙂  
Thanks and happy learning

Rosa

---

<div class="post-metadata">

**Author:** ![olofssonjon](https://avatars.discourse-cdn.com/v4/letter/o/f14d63/32.png) [@olofssonjon](https://community.deeplearning.ai/u/olofssonjon)\
**Post date:** [May 6, 2021, 7:06pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/5 "2021-05-06T19:06:08Z")

</div>

Please share how you fixed this, I have exactly the same problem. I have tried to restart the Kernel as was suggested in another thread.

The problem seems to arise in the last part of the code where I use

> model = Model(inputs=[X, a0, c0], outputs=outputs)

is this correct?

Problem solved. I went back and read the hint for part 2D of the exercise carefully.

---

<div class="post-metadata">

**Author:** ![hafezgh](https://avatars.discourse-cdn.com/v4/letter/h/8e8cbc/32.png) [@hafezgh](https://community.deeplearning.ai/u/hafezgh)\
**Post date:** [May 14, 2021, 9:48pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/6 "2021-05-14T21:48:37Z")

</div>

How did you resolve it?

---

<div class="post-metadata">

**Author:** ![ad\_4540](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ad\_4540](https://community.deeplearning.ai/u/ad_4540)\
**Post date:** [May 16, 2021, 1:24pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/7 "2021-05-16T13:24:58Z")

</div>

Can you please tell me how you fixed this error?

---

<div class="post-metadata">

**Author:** ![wugi.kim](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/wugi.kim/32/12258_2.png) [@wugi.kim](https://community.deeplearning.ai/u/wugi.kim)\
**Post date:** [May 28, 2021, 8:16am UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/8 "2021-05-28T08:16:48Z")

</div>

Read “Step 2.D” instruction carefully.

---

<div class="post-metadata">

**Author:** ![akhtarh](https://avatars.discourse-cdn.com/v4/letter/a/9f8e36/32.png) [@akhtarh](https://community.deeplearning.ai/u/akhtarh)\
**Post date:** [May 30, 2021, 2:43pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/9 "2021-05-30T14:43:07Z")

</div>

after reading 2D carefully still could not resolve it. any other hint will be appreciated

---

<div class="post-metadata">

**Author:** ![alinturlac](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/alinturlac/32/2392_2.png) [@alinturlac](https://community.deeplearning.ai/u/alinturlac)\
**Post date:** [June 2, 2021, 7:02pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/12 "2021-06-02T19:02:01Z")

</div>

Step 2.D tells you some important things, along with the documentation of tensorflow:  
[tf.math.argmax &nbsp;|&nbsp; TensorFlow Core v2.5.0](https://www.tensorflow.org/api_docs/python/tf/math/argmax) tells us there’s an “axis” parameter. there’s also a mention of “axis” in the 2D hints.  
[tf.one\_hot &nbsp;|&nbsp; TensorFlow Core v2.5.0](https://www.tensorflow.org/api_docs/python/tf/one_hot) also mentions a depth parameter that could be important for the final shapes

Hope this helps and is vague enough to count as a “hint”

---

<div class="post-metadata">

**Author:** ![Surili](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Surili](https://community.deeplearning.ai/u/Surili)\
**Post date:** [June 3, 2021, 12:46pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/13 "2021-06-03T12:46:14Z")

</div>

I am getting the same error. How did you resolve the error?

---

<div class="post-metadata">

**Author:** ![Sascha](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Sascha](https://community.deeplearning.ai/u/Sascha)\
**Post date:** [August 1, 2021, 11:45am UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/14 "2021-08-01T11:45:38Z")

</div>

Thanks for your post. However, under 2.D I have the following hint:

#### 2D. Dense layer

- Propagate the LSTM’s hidden state through a dense+softmax layer using `densor` .

---

<div class="post-metadata">

**Author:** ![coyne44](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/coyne44/32/2386_2.png) [@coyne44](https://community.deeplearning.ai/u/coyne44)\
**Post date:** [August 10, 2021, 8:21pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/15 "2021-08-10T20:21:09Z")

</div>

The answer to look at 2D more carefully is for problem 3 - Generating Music, not problem 2 - Building the Model. My answer is for problem 2 - Building the Model.

I got this exact same error but it had to do with my answer for 2C. Within the LSTM\_cell function,  
I set the initial state to [a0, c0]. However, that will only work for the first value of Tx and never gets updated after that. The variables a and c were initialized to a0 and c0 before the for loop. Once I changed the initial state to the correct variables, it worked.

---

<div class="post-metadata">

**Author:** ![salih-g](https://avatars.discourse-cdn.com/v4/letter/s/a9a28c/32.png) [@salih-g](https://community.deeplearning.ai/u/salih-g)\
**Post date:** [November 28, 2021, 12:42pm UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/16 "2021-11-28T12:42:29Z")

</div>

You need not use the `Lambda` function of keras. Instead just mention `x = (lambda x: x[:,t,:])(X)`

This should resolve it

---

<div class="post-metadata">

**Author:** ![Senura\_Ruvinda\_Ferna](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/senura_ruvinda_ferna/32/8851_2.png) [@Senura\_Ruvinda\_Ferna](https://community.deeplearning.ai/u/Senura_Ruvinda_Ferna)\
**Post date:** [February 4, 2022, 3:09am UTC](https://community.deeplearning.ai/t/dls-course-5-week-1-assignment-3/3054/17 "2022-02-04T03:09:33Z")

</div>

Thanks coyne44. This helped me to fix my error. initial state should be initialized using a and c
