Skip to content

Instantly share code, notes, and snippets.

@dpressel
Created July 5, 2017 17:28
Show Gist options
  • Select an option

  • Save dpressel/2aea46cc0d211b530d6afb1fed7bd0d2 to your computer and use it in GitHub Desktop.

Select an option

Save dpressel/2aea46cc0d211b530d6afb1fed7bd0d2 to your computer and use it in GitHub Desktop.
Run baseline classifier model in a REPL
from baseline import classifier_repl
# You can use any of the implementations interchangeably!
from baseline.keras.classify import ConvModel
import argparse
"""
Example of loading a previously trained classifier (in Keras) and interacting
with it using a shell. Your shell inputs (for the time being) should be
in the form the model tokenizes its training data.
"""
parser = argparse.ArgumentParser(description='Type some tokenized text')
parser.add_argument('--model', help='Model file', default='classifier-model-keras')
args = parser.parse_args()
model = ConvModel.load(args.model)
classifier_repl(model)
# E.g.
# class> this is garbage
# Guess [0]: 0.995
# class> this is totally amazing !
# Guess [1]: 1.000
# class> quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment