Skip to content

Instantly share code, notes, and snippets.

@wfng92
Last active June 19, 2019 02:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wfng92/7329eab023dac6c7b1640c429210ac72 to your computer and use it in GitHub Desktop.
Save wfng92/7329eab023dac6c7b1640c429210ac72 to your computer and use it in GitHub Desktop.
from . import run_classifier
import os
import tensorflow as tf
import json
def getListPrediction(in_sentences):
#1
input_examples = [run_classifier.InputExample(guid="", text_a = x, text_b = None, label = "0") for x in in_sentences] # here, "" is just a dummy label
#2
input_features = run_classifier.convert_examples_to_features(input_examples, label_list, MAX_SEQ_LENGTH, tokenizer)
#3
predict_input_fn = run_classifier.input_fn_builder(features=input_features, seq_length=MAX_SEQ_LENGTH, is_training=False, drop_remainder=False)
#4
predictions = estimator.predict(input_fn=predict_input_fn)
return predictions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment