# tf.contrib.eager.Saver

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/eager/python/saver.py#L116-L172) |

A tf.compat.v1.train.Saver adapter for use when eager execution is enabled.

    tf.contrib.eager.Saver(
        var_list
    )

`Saver`'s name-based checkpointing strategy is fragile. Please switch to
[`tf.train.Checkpoint`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/train/Checkpoint) or [`tf.keras.Model.save_weights`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/keras/Model#save_weights), which perform a more
robust object-based saving. These APIs will load checkpoints written by
`Saver`.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `var_list` | The list of variables that will be saved and restored. Either a list of [`tf.Variable`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/Variable) objects, or a dictionary mapping names to [`tf.Variable`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/Variable) objects. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `RuntimeError` | if invoked when eager execution has not been enabled. |

<br />

## Methods

### `restore`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/eager/python/saver.py#L163-L172)

    restore(
        file_prefix
    )

Restores previously saved variables.

<br />

<br />

<br />

| Args ||
|---|---|
| `file_prefix` | Path prefix where parameters were previously saved. Typically obtained from a previous `save()` call, or from [`tf.train.latest_checkpoint`](https://www.tensorflow.org/versions/r1.15/api_docs/python/tf/train/latest_checkpoint). |

<br />

### `save`

[View source](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/eager/python/saver.py#L145-L161)

    save(
        file_prefix, global_step=None
    )

Saves variables.

<br />

<br />

<br />

| Args ||
|---|---|
| `file_prefix` | Path prefix of files created for the checkpoint. |
| `global_step` | If provided the global step number is appended to file_prefix to create the checkpoint filename. The optional argument can be a Tensor, a Variable, or an integer. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A string: prefix of filenames created for the checkpoint. This may be an extension of file_prefix that is suitable to pass as an argument to a subsequent call to `restore()`. ||

<br />