Skip to content

Instantly share code, notes, and snippets.

@Justin-Heer
Created August 16, 2020 18:31
Show Gist options
  • Save Justin-Heer/1de0c1c0e82621ef05a654978e2176e7 to your computer and use it in GitHub Desktop.
Save Justin-Heer/1de0c1c0e82621ef05a654978e2176e7 to your computer and use it in GitHub Desktop.
testing the model accuracy on the test set
# load the weights for the optimal model
lstm_model.load_weights('biLSTM.h5')
# Converts a class vector (integers) to binary class matrix
# for use with categorical_crossentropy
# IMPORTANT for CATEGORICAL_CROSSENTROPY!
y_test = np_utils.to_categorical(y_test, 2)
# generator for validating the LSTM model
test_gen = generate_batch(X_test, y_test, batch_size, expected_frames)
# checks the models performance
accu_test = lstm_model.evaluate(test_gen,
steps=len(X_test) // batch_size,
verbose=1)
# print the test result
print(f'The test accuracy for this model is {accu_test[1] * 100:0.2f}%')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment