title: How to use loaded LSTM attention model to make predictions on input?
body: <p>I am a complete beginner in Deep Learning &amp; Keras. I want to build a hierarchical attention network that helps to classify comments into several categories viz. toxic, severely toxic, etc. I took the code from an open repository and saved the model. I then loaded the model using model_from_json. Now I wish to use this loaded model to make predictions on the input text(given as a python input or as a separate file).</p>
  
  <p>This is the code that I am using: <a href="https://www.kaggle.com/sermakarevich/hierarchical-attention-network/notebook" rel="nofollow noreferrer">https://www.kaggle.com/sermakarevich/hierarchical-attention-network/notebook</a></p>
  
  <h1>Then I did:</h1>
  
  <pre><code>model_json = model.to_json()
  with open("model.json", "w") as json_file:
      json_file.write(model_json)
  model.save_weights("model.h5")
  print("Saved model to disk")
  </code></pre>
  
  <h1>Then in a separate file:</h1>
  
  <pre><code>json_file = open('model.json', 'r')
  loaded_model_json = json_file.read()
  json_file.close()
  loaded_model = model_from_json(loaded_model_json,custom_objects={'AttentionWithContext':AttentionWithContext})
  loaded_model.load_weights("model.h5")
  print("Loaded model from disk")
  </code></pre>
  
  <p>I am getting "loaded model from disk" perfectly. I wish to know the format in which I need to give input and how and the code snippet to use the model to classify it. Since I do not have much knowledge about it, It would be really helpful if someone could help me with the python specific code to make it work.</p>