Estimators provide the following benefits:
-* You can run Estimators-based models on a local host or on a
+* You can run Estimator-based models on a local host or on a
distributed multi-server environment without changing your model.
- Furthermore, you can run Estimators-based models on CPUs, GPUs,
+ Furthermore, you can run Estimator-based models on CPUs, GPUs,
or TPUs without recoding your model.
* Estimators simplify sharing implementations between model developers.
-* You can develop a state of the art model with high-level intuitive code,
+* You can develop a state of the art model with high-level intuitive code.
In short, it is generally much easier to create models with Estimators
than with the low-level TensorFlow APIs.
-* Estimators are themselves built on tf.layers, which
+* Estimators are themselves built on @{tf.layers}, which
simplifies customization.
-* Estimators build the graph for you. In other words, you don't have to
- build the graph.
+* Estimators build the graph for you.
* Estimators provide a safe distributed training loop that controls how and
when to:
* build the graph
pre-made Estimators let you experiment with different model architectures by
making only minimal code changes. @{tf.estimator.DNNClassifier$`DNNClassifier`},
for example, is a pre-made Estimator class that trains classification models
-through dense, feed-forward neural networks.
+based on dense, feed-forward neural networks.
### Structure of a pre-made Estimators program
an input function:
def input_fn(dataset):
- ... # manipulate dataset, extracting feature names and the label
+ ... # manipulate dataset, extracting the feature dict and the label
return feature_dict, label
(See @{$programmers_guide/datasets} for full details.)
population = tf.feature_column.numeric_column('population')
crime_rate = tf.feature_column.numeric_column('crime_rate')
median_education = tf.feature_column.numeric_column('median_education',
- normalizer_fn='lambda x: x - global_education_mean')
+ normalizer_fn=lambda x: x - global_education_mean)
3. **Instantiate the relevant pre-made Estimator.** For example, here's
a sample instantiation of a pre-made Estimator named `LinearClassifier`:
# Instantiate an estimator, passing the feature columns.
- estimator = tf.estimator.Estimator.LinearClassifier(
+ estimator = tf.estimator.LinearClassifier(
feature_columns=[population, crime_rate, median_education],
)