# tf.estimator.LatestExporter

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/exporter.py#L421-L509) |

This class regularly exports the serving graph and checkpoints. (deprecated)

Inherits From: [`Exporter`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/estimator/Exporter)

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.estimator.LatestExporter`](https://www.tensorflow.org/api_docs/python/tf/estimator/LatestExporter)

<br />

    tf.estimator.LatestExporter(
        name,
        serving_input_receiver_fn,
        assets_extra=None,
        as_text=False,
        exports_to_keep=5
    )

> [!WARNING]
> **Deprecated:** THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use tf.keras instead.

In addition to exporting, this class also garbage collects stale exports.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `name` | unique name of this `Exporter` that is going to be used in the export path. |
| `serving_input_receiver_fn` | a function that takes no arguments and returns a `ServingInputReceiver`. |
| `assets_extra` | An optional dict specifying how to populate the assets.extra directory within the exported SavedModel. Each key should give the destination path (including the filename) relative to the assets.extra directory. The corresponding value gives the full path of the source file to be copied. For example, the simple case of copying a single file without renaming it is specified as `{'my_asset_file.txt': '/path/to/my_asset_file.txt'}`. |
| `as_text` | whether to write the SavedModel proto in text format. Defaults to `False`. |
| `exports_to_keep` | Number of exports to keep. Older exports will be garbage-collected. Defaults to 5. Set to `None` to disable garbage collection. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | if any arguments is invalid. |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `name` | Directory name. <br /> A directory name under the export base directory where exports of this type are written. Should not be `None` nor empty. |

<br />

## Methods

### `export`

[View source](https://github.com/tensorflow/estimator/tree/master/tensorflow_estimator/python/estimator/exporter.py#L469-L477)

    export(
        estimator, export_path, checkpoint_path, eval_result, is_the_final_export
    )

Exports the given `Estimator` to a specific format.

<br />

<br />

<br />

| Args ||
|---|---|
| `estimator` | the `Estimator` to export. |
| `export_path` | A string containing a directory where to write the export. |
| `checkpoint_path` | The checkpoint path to export. |
| `eval_result` | The output of [`Estimator.evaluate`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/compat/v1/estimator/Estimator#evaluate) on this checkpoint. |
| `is_the_final_export` | This boolean is True when this is an export in the end of training. It is False for the intermediate exports during the training. When passing `Exporter` to [`tf.estimator.train_and_evaluate`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/estimator/train_and_evaluate) `is_the_final_export` is always False if [`TrainSpec.max_steps`](https://www.tensorflow.org/versions/r2.13/api_docs/python/tf/estimator/TrainSpec#max_steps) is `None`. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| The string path to the exported directory or `None` if export is skipped. ||

<br />