# C5W1A3 - Jazz Improvisation - \*\*UPDATE\*\* Issue solved | ERROR at "model = djmodel(Tx=30, LSTM\_cell=LSTM\_cell, densor=densor, reshaper=reshaper)"

**URL:** <https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378>\
**Category:** Sequence Models\
**Tags:** coursera-platform\
**Created:** [August 10, 2021, 4:49am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378 "2021-08-10T04:49:20Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajeshm99](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rajeshm99/32/5066_2.png) [@rajeshm99](https://community.deeplearning.ai/u/rajeshm99)\
**Post date:** [August 10, 2021, 4:49am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/1 "2021-08-10T04:49:21Z")

</div>

**UPDATE** Issue solved = Had to restart kernel.

I followed the hints correctly and filled in the appropriate code in the djmodel() function. But I seem to get the below error when running the next code cell not matter what I do.  
Kindly help me understand this error!

djmodel Code:  
{moderator edit: code removed}

## Error:

ValueError Traceback (most recent call last)  
 in   
----\> 1 model = djmodel(Tx=30, LSTM\_cell=LSTM\_cell, densor=densor, reshaper=reshaper)

in djmodel(Tx, LSTM\_cell, densor, reshaper)  
46 a, \_, c = LSTM\_cell(inputs=x, initial\_state=[a, c])  
47 # Step 2.D: Apply densor to the hidden state output of LSTM\_Cell  
—\> 48 out = densor(a)  
49 # Step 2.E: add the output to “outputs”  
50 outputs.append(out)

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base\_layer.py in **call** (self, \*args, \*\*kwargs)  
924 if \_in\_functional\_construction\_mode(self, inputs, args, kwargs, input\_list):  
925 return self.\_functional\_construction\_call(inputs, args, kwargs,  
 → 926 input\_list)  
927  
928 # Maintains info about the `Layer.call` stack.

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base\_layer.py in \_functional\_construction\_call(self, inputs, args, kwargs, input\_list)  
1090 # TODO(reedwm): We should assert input compatibility after the inputs  
1091 # are casted, not before.  
 → 1092 input\_spec.assert\_input\_compatibility(self.input\_spec, inputs, self.name)  
1093 graph = backend.get\_graph()  
1094 # Use `self._name_scope()` to avoid auto-incrementing the name.

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/input\_spec.py in assert\_input\_compatibility(input\_spec, inputs, layer\_name)  
214 ’ incompatible with the layer: expected axis ’ + str(axis) +  
215 ’ of input shape to have value ’ + str(value) +  
 → 216 ’ but received input with shape ’ + str(shape))  
217 # Check shape.  
218 if spec.shape is not None:

ValueError: Input 0 of layer dense is incompatible with the layer: expected axis -1 of input shape to have value 90 but received input with shape [None, 64]

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [August 10, 2021, 6:06am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/2 "2021-08-10T06:06:11Z")

</div>

I think the problem is in your call to LSTM\_cell().  
Try removing the “inputs=” label from the '‘x’ variable.

---

<div class="post-metadata">

**Author:** ![rajeshm99](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rajeshm99/32/5066_2.png) [@rajeshm99](https://community.deeplearning.ai/u/rajeshm99)\
**Post date:** [August 10, 2021, 6:18am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/3 "2021-08-10T06:18:36Z")

</div>

@TMosh thanks for the reply. It worked fine after I restarted the Kernel, no changes made.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [August 10, 2021, 6:31am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/4 "2021-08-10T06:31:20Z")

</div>

Thanks for your report.

---

<div class="post-metadata">

**Author:** ![PolarBarrel](https://avatars.discourse-cdn.com/v4/letter/p/d9b06d/32.png) [@PolarBarrel](https://community.deeplearning.ai/u/PolarBarrel)\
**Post date:** [October 25, 2021, 7:28pm UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/5 "2021-10-25T19:28:13Z")

</div>

Had the same issue and a kernel restart worked for me as well

---

<div class="post-metadata">

**Author:** ![ferdinando.randisi](https://avatars.discourse-cdn.com/v4/letter/f/71c47a/32.png) [@ferdinando.randisi](https://community.deeplearning.ai/u/ferdinando.randisi)\
**Post date:** [June 25, 2022, 6:40pm UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/6 "2022-06-25T18:40:44Z")

</div>

Similar issue, but with a different error. My code looked exactly like the one above and worked correctly after a kernel restart

---

<div class="post-metadata">

**Author:** ![anon57530071](https://avatars.discourse-cdn.com/v4/letter/a/46a35a/32.png) [@anon57530071](https://community.deeplearning.ai/u/anon57530071)\
**Post date:** [June 25, 2022, 6:51pm UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/7 "2022-06-25T18:51:24Z")

</div>

Please see this [thread](https://community.deeplearning.ai/t/not-understanding-why-getting-this-error/141808).

The problem is LSTM\_cell is defined as a global variable, and is easily broken during debugging. So, you need to reset LSTM\_cell like this if there is an error.

> LSTM\_cell = LSTM(n\_a, return\_state = True)

Of course, this resets trained weights as well. So, once you fix an error, it is better to re-run all cells.  
But, do not need to restart kernel everytime for debugging.

---

<div class="post-metadata">

**Author:** ![Rashmi](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rashmi/32/17812_2.png) [@Rashmi](https://community.deeplearning.ai/u/Rashmi)\
**Post date:** [June 29, 2022, 9:39am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/8 "2022-06-29T09:39:02Z")

</div>

Hi Rajeshm99,

Posting the codes at this platform is a violation. If the query is resolved completely, kindly remove it.

Thanks!

---

<div class="post-metadata">

**Author:** ![rajeshm99](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rajeshm99/32/5066_2.png) [@rajeshm99](https://community.deeplearning.ai/u/rajeshm99)\
**Post date:** [June 29, 2022, 2:41pm UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/9 "2022-06-29T14:41:50Z")

</div>

Hi Rashmi, I’m unable to delete the code as I’m not able to edit the post.  
Thanks!

---

<div class="post-metadata">

**Author:** ![Rashmi](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/rashmi/32/17812_2.png) [@Rashmi](https://community.deeplearning.ai/u/Rashmi)\
**Post date:** [June 30, 2022, 7:30am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/10 "2022-06-30T07:30:47Z")

</div>

Oh, yes. Even I’m not able to do so. I think it would be done by the moderator.

---

<div class="post-metadata">

**Author:** ![TMosh](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/tmosh/32/9321_2.png) [@TMosh](https://community.deeplearning.ai/u/TMosh)\
**Post date:** [October 8, 2022, 3:00am UTC](https://community.deeplearning.ai/t/c5w1a3-jazz-improvisation-update-issue-solved-error-at-model-djmodel-tx-30-lstm-cell-lstm-cell-densor-densor-reshaper-reshaper/26378/11 "2022-10-08T03:00:53Z")

</div>


