Music_inference_model

def music_inference_model(LSTM_cell, densor, Ty=100):
“”"
Uses the trained “LSTM_cell” and “densor” from model() to generate a sequence of values.

Arguments:
LSTM_cell -- the trained "LSTM_cell" from model(), Keras layer object
densor -- the trained "densor" from model(), Keras layer object
Ty -- integer, number of time steps to generate

Returns:
inference_model -- Keras model instance
"""

# Get the shape of input values
n_values = densor.units
# Get the number of the hidden state vector
n_a = LSTM_cell.units

# Define the input of your model with a shape 
x0 = Input(shape=(1, n_values))


# Define s0, initial hidden state for the decoder LSTM
a0 = Input(shape=(n_a,), name='a0')
c0 = Input(shape=(n_a,), name='c0')
a = a0
c = c0
x = x0

### START CODE HERE ###
# Step 1: Create an empty list of "outputs" to later store your predicted values (≈1 line)
outputs = []

# Step 2: Loop over Ty and generate a value at every time step
for t in range(Ty):
    
    # Step 2.A: Perform one step of LSTM_cell (≈1 line)
    a, _, c = LSTM_cell(x, initial_state=[a, c])
    
    # Step 2.B: Apply Dense layer to the hidden state output of the LSTM_cell (≈1 line)
    out = densor(a)

    # Step 2.C: Append the prediction "out" to "outputs". out.shape = (None, 78) (≈1 line)
    outputs.append(out)

    
    index = tf.math.argmax(out,axis=-1) 
    x = tf.one_hot(index,n_values)
    x = RepeatVector(1)(x)
    
# Step 3: Create model instance with the correct "inputs" and "outputs" (≈1 line)
inference_model = Model(inputs=[x0, a0, c0], outputs=outputs)

### END CODE HERE ###

return inference_model

it is showing error in :
ValueError Traceback (most recent call last)
in
----> 1 inference_model = music_inference_model(LSTM_cell, densor, Ty = 50)

in music_inference_model(LSTM_cell, densor, Ty)
39
40 # Step 2.A: Perform one step of LSTM_cell (≈1 line)
—> 41 a, _, c = LSTM_cell(x, initial_state=[a, c])
42
43 # Step 2.B: Apply Dense layer to the hidden state output of the LSTM_cell (≈1 line)

/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)
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)
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 13 inputs, but it received 3 input tensors. Inputs received: [<tf.Tensor ‘input_38:0’ shape=(None, 1, 90) dtype=float32>, <tf.Tensor ‘a0_37:0’ shape=(None, 64) dtype=float32>, <tf.Tensor ‘c0_37:0’ shape=(None, 64) dtype=float32>]

can any one help me to fix the error

Restart the whole kernel and execute all of your cells again