Skip to content

Instantly share code, notes, and snippets.

@random-forests
Created March 30, 2018 19:07
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 random-forests/8d9049c407d5b7fff613ccb585ce7299 to your computer and use it in GitHub Desktop.
Save random-forests/8d9049c407d5b7fff613ccb585ce7299 to your computer and use it in GitHub Desktop.
Snippet for TF blog
# Use pre-trained universal sentence encoder to build text vector
review = hub.text_embedding_column(
“review”, “https://tfhub.dev/google/universal-sentence-encoder/1")
features = {
“review”: np.array([“this movie is a masterpiece”, “this movie was terrible”, …])
}
labels = np.array([[1], [0], …])
input_fn = tf.estimator.input.numpy_input_fn(features, labels, shuffle=True)
estimator = tf.estimator.DNNClassifier(hidden_units, [review])
estimator.train(input_fn, max_steps=100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment