Created
March 30, 2018 19:07
-
-
Save random-forests/8d9049c407d5b7fff613ccb585ce7299 to your computer and use it in GitHub Desktop.
Snippet for TF blog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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