title: How do I fit the model of two concatenate LSTM in keras?
body: <p>Hi I'm new in keras and I concatenate two LSTM in keras. The dataset is a univariate time series which was split by the method sliding window. Then I reshaped it as a tesor of [samples, features,time steps]. However when I tried to fit the model the following error appears.</p>
  <p>TypeError: in user code:</p>
  <pre><code>/usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/training.py:806 train_function  *
      return step_function(self, iterator)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/training.py:796 step_function  **
      outputs = model.distribute_strategy.run(run_step, args=(data,))
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/distribute/distribute_lib.py:1211 run
      return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/distribute/distribute_lib.py:2585 call_for_each_replica
      return self._call_for_each_replica(fn, args, kwargs)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/distribute/distribute_lib.py:2945 _call_for_each_replica
      return fn(*args, **kwargs)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/training.py:789 run_step  **
      outputs = model.train_step(data)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/training.py:747 train_step
      y_pred = self(x, training=True)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py:985 __call__
      outputs = call_fn(inputs, *args, **kwargs)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/sequential.py:386 call
      outputs = layer(inputs, **kwargs)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py:982 __call__
      self._maybe_build(inputs)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/engine/base_layer.py:2643 _maybe_build
      self.build(input_shapes)  # pylint:disable=not-callable
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/utils/tf_utils.py:323 wrapper
      output_shape = fn(instance, input_shape)
  /usr/local/lib/python3.8/dist-packages/tensorflow/python/keras/layers/merge.py:500 build
      del reduced_inputs_shapes[i][self.axis]
  
  TypeError: list indices must be integers or slices, not ListWrapper
  </code></pre>
  <p>How should I pass trainX and testX? I want to do somenthing like in this image:</p>
  <p><a href="https://i.stack.imgur.com/V7RKx.png" rel="nofollow noreferrer">LSTMdata</a></p>
  <p>The code is the following</p>
  <pre><code> trainX = numpy.reshape(trainX, (trainX.shape[0],1, trainX.shape[1]))
   testX = numpy.reshape(testX, (testX.shape[0], 1,testX.shape[1]))
  
   model1= Sequential()
   model1.add(LSTM(6, input_shape=(1,look_back)))
  
   model2 = Sequential()
   model2.add(LSTM(6, input_shape=(1,look_back)))
  
   model = Sequential()
   model.add(Concatenate([model1, model1]))
   model.add(Dense(1))
  
   model.compile(loss='mean_squared_error', optimizer='adam', metrics = ['mse'])
  
   model.fit([trainX, trainX], trainY, epochs=50, batch_size=1, verbose=1)
  </code></pre>