Jazz Improvisation - UNQ_C1(djmodel)

Dear all,

I have no clue were I am going wrong. I would appreciate some help.

Below are the exception errors.

Thank you all

ValueError                                Traceback (most recent call last)
<ipython-input-38-d2753e0c7a2d> in <module>
----> 1 model = djmodel(Tx=30, LSTM_cell=LSTM_cell, densor=densor, reshaper=reshaper)

<ipython-input-37-7b444d6ac3de> in djmodel(Tx, LSTM_cell, densor, reshaper)
     47         x = reshaper(x)
     48         # Step 2.C: Perform one step of the LSTM_cell
---> 49         a, _, c = LSTM_cell(inputs = x, initial_state = [a, c])
     50         # Step 2.D: Apply densor to the hidden state output of LSTM_Cell
     51         out = densor(layer_object(a))

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/recurrent.py in __call__(self, inputs, initial_state, constants, **kwargs)
    707       # Perform the call with temporarily replaced input_spec
    708       self.input_spec = full_input_spec
--> 709       output = super(RNN, self).__call__(full_input, **kwargs)
    710       # Remove the additional_specs from input spec and keep the rest. It is
    711       # important to keep since the input spec was populated by build(), and

/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)
    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)
    156                      str(len(input_spec)) + ' inputs, '
    157                      'but it received ' + str(len(inputs)) +
--> 158                      ' input tensors. Inputs received: ' + str(inputs))
    159   for input_index, (x, spec) in enumerate(zip(inputs, input_spec)):
    160     if spec is None:

ValueError: Layer lstm_1 expects 15 inputs, but it received 3 input tensors. Inputs received: [<tf.Tensor 'reshape_1/Reshape_6:0' shape=(30, 1, 90) dtype=float32>, <tf.Tensor 'a0_8:0' shape=(None, 64) dtype=float32>, <tf.Tensor 'c0_8:0' shape=(None, 64) dtype=float32>]

Please click my name and message your notebook as an attachment.

Your slicing of X is incorrect in the 1st Step 2.A.
X is of shape (m, Tx, n_values)

Thanks Balaji for pointing it out. Have not figured out how to correct it. Tried X[:,t,:], but shape of x is (None, 1, 90).

Will get back to this issue later on.

Have a nice weekend.

Hi Balaji,

I have reviewed my code, but it is still incorrect. I really don’t know how to go forward.

Can you explain eventually in the open forum what the following steps in 2A mean? I have difficulty understanding the shape of the t slice and why the slicing in numpy is [:,1,:], i.e., why the 1 in the 2nd dimension.

Thank you.

[code removed - moderator]

Don’t post your notebook in public. I asked you to send a direct message.

The problem with your code is in the range of timesteps you consider. Did you have a reason to start the range at 1?