A function that provides input data for training as minibatches.
See Premade Estimators
for more information. The function should construct and return one of
the following:
A 'tf.data.Dataset' object: Outputs of Dataset object must be a
tuple (features, labels) with same constraints as below.
A tuple (features, labels): Where features is a Tensor or a
dictionary of string feature name to Tensor and labels is a
Tensor or a dictionary of string label name to Tensor.
max_steps
Int. Positive number of total steps for which to train model.
If None, train forever. The training input_fn is not expected to
generate OutOfRangeError or StopIteration exceptions. See the
train_and_evaluate stop condition section for details.
hooks
Iterable of tf.train.SessionRunHook objects to run on all workers
(including chief) during training.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tf.estimator.TrainSpec\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/training.py#L127-L197) |\n\nConfiguration for the \"train\" part for the `train_and_evaluate` call. (deprecated)\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.estimator.TrainSpec`](https://www.tensorflow.org/api_docs/python/tf/estimator/TrainSpec)\n\n\u003cbr /\u003e\n\n tf.estimator.TrainSpec(\n input_fn, max_steps=None, hooks=None, saving_listeners=None\n )\n\n| **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use tf.keras instead.\n\n`TrainSpec` determines the input data for the training, as well as the\nduration. Optional hooks run at various stages of training.\n\n#### Usage:\n\n train_spec = tf.estimator.TrainSpec(\n input_fn=lambda: 1,\n max_steps=100,\n hooks=[_StopAtSecsHook(stop_after_secs=10)],\n saving_listeners=[_NewCheckpointListenerForEvaluate(None, 20, None)])\n train_spec.saving_listeners[0]._eval_throttle_secs\n 20\n train_spec.hooks[0]._stop_after_secs\n 10\n train_spec.max_steps\n 100\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `input_fn` | A function that provides input data for training as minibatches. See [Premade Estimators](https://tensorflow.org/guide/premade_estimators#create_input_functions) for more information. The function should construct and return one of the following: \u003cbr /\u003e - A 'tf.data.Dataset' object: Outputs of `Dataset` object must be a tuple (features, labels) with same constraints as below. - A tuple (features, labels): Where features is a `Tensor` or a dictionary of string feature name to `Tensor` and labels is a `Tensor` or a dictionary of string label name to `Tensor`. |\n| `max_steps` | Int. Positive number of total steps for which to train model. If `None`, train forever. The training `input_fn` is not expected to generate `OutOfRangeError` or `StopIteration` exceptions. See the `train_and_evaluate` stop condition section for details. |\n| `hooks` | Iterable of `tf.train.SessionRunHook` objects to run on all workers (including chief) during training. |\n| `saving_listeners` | Iterable of [`tf.estimator.CheckpointSaverListener`](../../tf/estimator/CheckpointSaverListener) objects to run on chief during training. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|------------------------------------------------------|\n| `ValueError` | If any of the input arguments is invalid. |\n| `TypeError` | If any of the arguments is not of the expected type. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------------------|-----------------------------------------|\n| `input_fn` | A `namedtuple` alias for field number 0 |\n| `max_steps` | A `namedtuple` alias for field number 1 |\n| `hooks` | A `namedtuple` alias for field number 2 |\n| `saving_listeners` | A `namedtuple` alias for field number 3 |\n\n\u003cbr /\u003e"]]