I am a complete beginner in Deep Learning & 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).
This is the code that I am using: https://www.kaggle.com/sermakarevich/hierarchical-attention-network/notebook
Then I did:
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")
Then in a separate file:
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")
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.