I have a basic question that I can't seem to find an answer to.

I built and trained with good results (above 90% accuracy) a NLP Log classifier that takes in a UTF-8 payload and classifies it into 32 distinct categories but I am having a hard time writing a simple script that loads all the necessary info from my training and testing session (model.h5 and ?).

This is the structure of my code.

# load data logs and split it 80-20 for training and testing
vocab_size = 500
tokenizer = text.Tokenizer(num_words=vocab_size)
x_train = tokenize.text_to_matrix(trainRawLogs)
x_test = tokenize.text_to_matrix(testRawLogs)

encoder = labelBinarizer()

#Model build is simple ReLu - Softmax




Now here is my question.

Out of all of this process what do I need to save to build a lightweight classifier? The model? The model and the labels? Anything else? I tried loading the model


1 Answer 1


In keras you have the option to save the entire model state including the optimizer parameters or simply the model weights. In the first case all you need to do is:

model = load_model(model_path)  

In the second case you have to first create your model and then load the weights:


In case model is not already specified:

model = Sequential()  




Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.