title: stacked GRU model in keras
body: <p>I am willing to create a GRU model of 3 layers where each layer will have 32,16,8 units respectively. The model would take analog calue as input and produce analog value as output.</p>
  
  <p>I have written the following code:</p>
  
  <pre><code>def getAModelGRU(neuron=(10), look_back=1, numInputs = 1, numOutputs = 1):
      model = Sequential()
      if len(neuron) &gt; 1:
          model.add(GRU(units=neuron[0], input_shape=(look_back,numInputs)))
          for i in range(1,len(neuron)-1):
              model.add(GRU(units=neuron[i]))
          model.add(GRU(units=neuron[-1], input_shape=(look_back,numInputs)))
      else:
      model.add(GRU(units=neuron, input_shape=(look_back,numInputs)))
      model.add(Dense(numOutputs))
      model.compile(loss='mean_squared_error', optimizer='adam')
      return model
  </code></pre>
  
  <p>And, I will call this function as: </p>
  
  <pre><code>chkEKF = getAModelGRU(neuron=(32,16,8), look_back=1, numInputs=10, numOutputs=6)
  </code></pre>
  
  <p>And, I obtained the following:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/momtaz/Dropbox/QuadCopter/quad_simHierErrorCorrectionEstimator.py", line 695, in &lt;module&gt;
      Single_Point2Point()
    File "/home/momtaz/Dropbox/QuadCopter/quad_simHierErrorCorrectionEstimator.py", line 74, in Single_Point2Point
      chkEKF = getAModelGRU(neuron=(32,16,8), look_back=1, numInputs=10, numOutputs=6)
    File "/home/momtaz/Dropbox/QuadCopter/rnnUtilQuad.py", line 72, in getAModelGRU
      model.add(GRU(units=neuron[i]))
    File "/home/momtaz/PycharmProjects/venv/lib/python3.6/site-packages/keras/engine/sequential.py", line 181, in add
      output_tensor = layer(self.outputs[0])
    File "/home/momtaz/PycharmProjects/venv/lib/python3.6/site-packages/keras/layers/recurrent.py", line 532, in __call__
      return super(RNN, self).__call__(inputs, **kwargs)
    File "/home/momtaz/PycharmProjects/venv/lib/python3.6/site-packages/keras/engine/base_layer.py", line 414, in __call__
      self.assert_input_compatibility(inputs)
    File "/home/momtaz/PycharmProjects/venv/lib/python3.6/site-packages/keras/engine/base_layer.py", line 311, in assert_input_compatibility
      str(K.ndim(x)))
  ValueError: Input 0 is incompatible with layer gru_2: expected ndim=3, found ndim=2
  
  </code></pre>
  
  <p>I tried online but did not find any solution for 'ndim' related issue.</p>
  
  <p>Please let me know which I am doing wrong here.</p>