title: Keras model load_weights for Neural Net
body: <p>I'm using the Keras library to create a neural network in python. I have loaded the training data (txt file), initiated the network and "fit" the weights of the neural network. I have then written code to generate the output text. Here is the code:</p>
  
  <pre><code>#!/usr/bin/env python
  
  # load the network weights
  filename = "weights-improvement-19-2.0810.hdf5"
  model.load_weights(filename)
  model.compile(loss='categorical_crossentropy', optimizer='adam')
  </code></pre>
  
  <p>My problem is: on execution the following error is produced:</p>
  
  <pre><code> model.load_weights(filename)
   NameError: name 'model' is not defined
  </code></pre>
  
  <p>I have added the following but the error still persists: </p>
  
  <pre><code>from keras.models import Sequential
  from keras.models import load_model
  </code></pre>
  
  <p>Any help would be appreciated.</p>