title: AttributeError: 'Model' object has no attribute 'epoch' - Keras
body: <p>I huild an auto encoder in keras following steps given in a simple autoencoder based on a fully-connected layer (<a href="https://blog.keras.io/building-autoencoders-in-keras.html" rel="nofollow noreferrer">https://blog.keras.io/building-autoencoders-in-keras.html</a>) </p>
  
  <pre><code>wiki_autoencoder.fit(wiki_train, wiki_train,
                  epochs=100,
                  batch_size=256,
                  shuffle=True,
                  validation_data=(wiki_test, wiki_test))  
  </code></pre>
  
  <p>After training and cross vaidation. plotting the results gives me error given below:</p>
  
  <pre><code>    loss = wiki_autoencoder.history.history['loss']
      val_loss = wiki_autoencoder.history.history['val_loss']
      epochs = range(epochs)
      plt.figure()
      plt.plot(epochs, loss, 'bo', label='Training loss')
      plt.plot(epochs, val_loss, 'b', label='Validation loss')
      plt.title('Training and validation loss')
      plt.legend()
      plt.show()
  
  
  NameError                                 Traceback (most recent call last)
  &lt;ipython-input-32-6acdd795daf3&gt; in &lt;module&gt;()
        1 loss = wiki_autoencoder.history.history['loss']
        2 val_loss = wiki_autoencoder.history.history['val_loss']
  ----&gt; 3 epochs = range(epochs)
        4 plt.figure()
        5 plt.plot(epochs, loss, 'bo', label='Training loss')
  
  NameError: name 'epochs' is not defined
  </code></pre>
  
  <p>The second thing i tried gives be result : No handles with labels found to put in legend. however plot is generated. how do i solve this problem</p>
  
  <p><a href="https://i.stack.imgur.com/jLMSt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jLMSt.png" alt="enter image description here"></a></p>
  
  <pre><code>plt.plot(wiki_autoencoder.history.history['val_loss'], 'r', wiki_autoencoder.history.history['loss'], 'bo')
  plt.xlabel('Epochs')
  plt.ylabel('Loss')
  plt.title('Training and validation loss')
  plt.legend()
  plt.show()
  </code></pre>