title: how to calculate the derivate value of Multi-input models in keras by with tensorflow backend
body: <p><a href="https://i.stack.imgur.com/t8wJ4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t8wJ4.png" alt="here is my nueral network. Use LSTM output as dense layer input. "></a></p>
  
  <p>My question is: I want to calculate the derivation of "time input" and "dense_input". Before asking question,  <a href="https://stackoverflow.com/questions/39561560/getting-gradient-of-model-output-w-r-t-weights-using-keras">I search the soluatoin of calculaing jacobian matrix by keras function.</a></p>
  
  <p>After running it, But I got this error:</p>
  
  <blockquote>
    <p>File "\keras\backend\tensorflow_backend.py", line 2614, in _call
        dtype=tensor.dtype.base_dtype.name))
    AttributeError: 'list' object has no attribute 'dtype'</p>
  </blockquote>
  
  <p>Here is my simple version:</p>
  
  <pre><code>from keras.models import *
  from keras.layers import *
  import keras.backend as K
  import pandas as pd
  from keras import optimizers
  def get_model(timestamp, features):
      time_input = Input(shape=(timestamp, features,), name='time_input')
      lstm_out = LSTM(4)(time_input)
  
      dense_hidden_units = 2
  
      dense_input_layer = Input(shape=(dense_length,), name='dense_input_layer')
      final_input_layer = concatenate([lstm_out, dense_input_layer])
  
      # Disable biases in the hidden layer
      dense_1 = Dense(units=dense_hidden_units, use_bias=False, activation='sigmoid')(final_input_layer)
      # Disable bias in output layer
      output_layer = Dense(units=1, use_bias=False, name='final_output')(dense_1)
  
      model = Model(
          inputs=[time_input, dense_input_layer],
          outputs=output_layer
      )
      print(model.summary())
  
      return model
  if __name__ == '__main__':
      timestamp = 3
      features = 1
      dense_length = 3
  
      temp_data = pd.DataFrame([
          [1, 2, 3, 2, 3, 4],
      ])
  
      time_data = temp_data.values.reshape(-1, timestamp, features)
      dense_data = temp_data.values.reshape(-1, dense_length)
      target_data = np.array([1, 2])
      print(time_data.shape)
      print(dense_data.shape)
      print(target_data.shape)
  
      model = get_model(
          timestamp, features
      )
  
      Ada = optimizers.Adagrad(lr=0.09, epsilon=1e-04)
      model.compile(loss='mse', optimizer=Ada, metrics=['mse'])
  
      model.fit(
          {
              'time_input': time_data,
              'dense_input_layer': dense_data,
          },
          {
              'final_output': target_data
          },
          epochs=1, batch_size=1
      )
  
      time_input = model.get_layer('time_input').input
      GPP_input_layer = model.get_layer('dense_input_layer').input
  
      J = K.gradients(model.output, [time_input, GPP_input_layer])
      jacobianTime = K.function([[time_input, GPP_input_layer], K.learning_phase()], J)
  
      deriRes = jacobianTime([time_data, dense_data]) # this line throw exception
  
      print(deriRes[0])
  </code></pre>
  
  <p>Thanks for help!</p>