train_and_evaluate.tf_estimator: Train and evaluate the estimator.

Description Usage Arguments Details Raises See Also

View source: R/train_and_evaluate.R

Description

(Available since TensorFlow v1.4)

Usage

1
2
## S3 method for class 'tf_estimator'
train_and_evaluate(object, train_spec, eval_spec, ...)

Arguments

object

An estimator object to train and evaluate.

train_spec

A TrainSpec instance to specify the training specification.

eval_spec

A EvalSpec instance to specify the evaluation and export specification.

...

Not used.

Details

This utility function trains, evaluates, and (optionally) exports the model by using the given estimator. All training related specification is held in train_spec, including training input_fn and training max steps, etc. All evaluation and export related specification is held in eval_spec, including evaluation input_fn, steps, etc.

This utility function provides consistent behavior for both local (non-distributed) and distributed configurations. Currently, the only supported distributed training configuration is between-graph replication.

Overfitting: In order to avoid overfitting, it is recommended to set up the training input_fn to shuffle the training data properly. It is also recommended to train the model a little longer, say multiple epochs, before performing evaluation, as the input pipeline starts from scratch for each training. It is particularly important for local training and evaluation.

Stop condition: In order to support both distributed and non-distributed configuration reliably, the only supported stop condition for model training is train_spec.max_steps. If train_spec.max_steps is NULL, the model is trained forever. Use with care if model stop condition is different. For example, assume that the model is expected to be trained with one epoch of training data, and the training input_fn is configured to throw OutOfRangeError after going through one epoch, which stops the Estimator.train. For a three-training-worker distributed configuration, each training worker is likely to go through the whole epoch independently. So, the model will be trained with three epochs of training data instead of one epoch.

Raises

See Also

Other training methods: eval_spec(), train_spec()


tfestimators documentation built on Aug. 10, 2021, 1:06 a.m.