title: Keras: AttributeError: 'Sequential' object has no attribute '_nested_inputs'
body: <p><strong>Overall Ask:</strong></p>
  <p>Hi all, I am getting an attribute error and I am not quite sure what the cause is. I am following this <a href="https://ekamperi.github.io/machine%20learning/2021/01/21/encoder-decoder-model.html" rel="nofollow noreferrer">autoencoder tutorial</a> and trying to replicate some of the code. Can you tell me where I am going wrong?</p>
  <p><strong>Autoencoder Build:</strong></p>
  <pre><code># This is the dimension of the original space
  input_dim = maxlen
  
  # This is the dimension of the latent space (encoding space)
  latent_dim = 2
  
  encoder = Sequential([
      Dense(128, activation='relu', input_shape=(input_dim,)),
      Dense(64, activation='relu'),
      Dense(32, activation='relu'),
      Dense(latent_dim, activation='relu')
  ])
  
  decoder = Sequential([
      Dense(64, activation='relu', input_shape=(latent_dim,)),
      Dense(128, activation='relu'),
      Dense(256, activation='relu'),
      Dense(input_dim, activation=None)
  ])
  </code></pre>
  <p>When the encoder and decoder are connected in the following part, this is when the error arises:</p>
  <pre><code>autoencoder = Model(inputs=encoder.input, outputs=decoder(encoder.output))
  </code></pre>
  <p><strong>The error:</strong></p>
  <pre><code>AttributeError: 'Sequential' object has no attribute '_nested_inputs'
  ---------------------------------------------------------------------------
  AttributeError                            Traceback (most recent call last)
  &lt;command-55734003&gt; in &lt;module&gt;
  ----&gt; 1 autoencoder = Model(inputs=encoder.input, outputs=decoder(encoder.output))
        2 
        3 autoencoder.compile(loss='mse', optimizer='adam')
  
  /databricks/python/lib/python3.8/site-packages/tensorflow/python/keras/engine/functional.py in input(self)
      241       AttributeError: If no inbound nodes are found.
      242     &quot;&quot;&quot;
  --&gt; 243     return self._nested_inputs
      244 
      245   @property
  
  AttributeError: 'Sequential' object has no attribute '_nested_inputs'
  </code></pre>
  <p><strong>What I tried:</strong></p>
  <ol>
  <li><p>I googled the error, and a <a href="https://github.com/keras-team/keras/issues/14238" rel="nofollow noreferrer">post</a> suggested altering the input shape. I do not know a lot about Autoencoders, but the architecture appears to already have this parameter.</p>
  </li>
  <li><p>Another <a href="https://stackoverflow.com/questions/63783420/tf-2-3-concatenate-error-attributeerror-sequential-object-has-no-attribute">post</a> suggested adding input_shape (which is already there), and then using build()</p>
  </li>
  </ol>
  <p>Any advice would be appreciated!</p>