Estimater
Estimator:代表一个完整的模型。Estimator API 提供一些方法来训练模型、判断模型的准确率并生成预测。
- https://www.tensorflow.org/get_started/premade_estimators
- https://www.tensorflow.org/programmers_guide/estimators
TF-Hub
TensorFlow Hub is a library to foster the publication, discovery, and consumption of reusable parts of machine learning models. A module is a self-contained piece of a TensorFlow graph, along with its weights and assets, that can be reused across different tasks in a process known as transfer learning.
1. text classification
sentence embedding models: Universal sentence encoder https://www.tensorflow.org/hub/modules/google/universal-sentence-encoder/1
- Transformer
- DAN(Deep average network)
Example
import tensorflow as tf
import tensorflow_hub as hub
with tf.Graph().as_default():
embed = hub.Module("https://tfhub.dev/google/nnlm-en-dim128-with-normalization/1")
embeddings = embed(["A long sentence.", "single-word", "http://example.com"])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(tf.tables_initializer())
print(sess.run(embeddings))