LostTech.TensorFlow : API Documentation

Type Saver

Namespace tensorflow.train

Parent PythonObjectContainer

Interfaces ISaver

Saves and restores variables.

See [Variables](https://tensorflow.org/guide/variables) for an overview of variables, saving and restoring.

The `Saver` class adds ops to save and restore variables to and from *checkpoints*. It also provides convenience methods to run these ops.

Checkpoints are binary files in a proprietary format which map variable names to tensor values. The best way to examine the contents of a checkpoint is to load it using a `Saver`.

Savers can automatically number checkpoint filenames with a provided counter. This lets you keep multiple checkpoints at different steps while training a model. For example you can number the checkpoint filenames with the training step number. To avoid filling up disks, savers manage checkpoint files automatically. For example, they can keep only the N most recent files, or one checkpoint for every N hours of training.

You number checkpoint filenames by passing a value to the optional `global_step` argument to `save()`: Additionally, optional arguments to the `Saver()` constructor let you control the proliferation of checkpoint files on disk:

* `max_to_keep` indicates the maximum number of recent checkpoint files to keep. As new files are created, older files are deleted. If None or 0, no checkpoints are deleted from the filesystem but only the last one is kept in the `checkpoint` file. Defaults to 5 (that is, the 5 most recent checkpoint files are kept.)

* `keep_checkpoint_every_n_hours`: In addition to keeping the most recent `max_to_keep` checkpoint files, you might want to keep one checkpoint file for every N hours of training. This can be useful if you want to later analyze how a model progressed during a long training session. For example, passing `keep_checkpoint_every_n_hours=2` ensures that you keep one checkpoint file for every 2 hours of training. The default value of 10,000 hours effectively disables the feature.

Note that you still have to call the `save()` method to save the model. Passing these arguments to the constructor will not save variables automatically for you.

A training program that saves regularly looks like: In addition to checkpoint files, savers keep a protocol buffer on disk with the list of recent checkpoints. This is used to manage numbered checkpoint files and by `latest_checkpoint()`, which makes it easy to discover the path to the most recent checkpoint. That protocol buffer is stored in a file named 'checkpoint' next to the checkpoint files.

If you create several savers, you can specify a different filename for the protocol buffer file in the call to `save()`.
Show Example
saver.save(sess, 'my-model', global_step=0) ==> filename: 'my-model-0'
           ...
            saver.save(sess, 'my-model', global_step=1000) ==> filename: 'my-model-1000' 

Methods

Properties

Public instance methods

object as_saver_def_dyn()

Generates a `SaverDef` representation of this saver.
Returns
object
A `SaverDef` proto.

object build_dyn()

Build a profiling option.
Returns
object
A dict of profiling options.

object export_meta_graph(IEnumerable<object> filename, object collection_list, bool as_text, object export_scope, Nullable<bool> clear_devices, bool clear_extraneous_savers, Saver strip_default_attrs, bool save_debug_info)

Writes `MetaGraphDef` to save_path/filename.
Parameters
IEnumerable<object> filename
Optional meta_graph filename including the path.
object collection_list
List of string keys to collect.
bool as_text
If `True`, writes the meta_graph as an ASCII proto.
object export_scope
Optional `string`. Name scope to remove.
Nullable<bool> clear_devices
Whether or not to clear the device field for an `Operation` or `Tensor` during export.
bool clear_extraneous_savers
Remove any Saver-related information from the graph (both Save/Restore ops and SaverDefs) that are not associated with this Saver.
Saver strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of filename and with `_debug` added before the file extension.
Returns
object
A `MetaGraphDef` proto.

object export_meta_graph(IEnumerable<object> filename, object collection_list, bool as_text, object export_scope, Nullable<bool> clear_devices, bool clear_extraneous_savers, bool strip_default_attrs, bool save_debug_info)

Writes `MetaGraphDef` to save_path/filename.
Parameters
IEnumerable<object> filename
Optional meta_graph filename including the path.
object collection_list
List of string keys to collect.
bool as_text
If `True`, writes the meta_graph as an ASCII proto.
object export_scope
Optional `string`. Name scope to remove.
Nullable<bool> clear_devices
Whether or not to clear the device field for an `Operation` or `Tensor` during export.
bool clear_extraneous_savers
Remove any Saver-related information from the graph (both Save/Restore ops and SaverDefs) that are not associated with this Saver.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of filename and with `_debug` added before the file extension.
Returns
object
A `MetaGraphDef` proto.

object export_meta_graph_dyn(object filename, object collection_list, ImplicitContainer<T> as_text, object export_scope, ImplicitContainer<T> clear_devices, ImplicitContainer<T> clear_extraneous_savers, ImplicitContainer<T> strip_default_attrs, ImplicitContainer<T> save_debug_info)

Writes `MetaGraphDef` to save_path/filename.
Parameters
object filename
Optional meta_graph filename including the path.
object collection_list
List of string keys to collect.
ImplicitContainer<T> as_text
If `True`, writes the meta_graph as an ASCII proto.
object export_scope
Optional `string`. Name scope to remove.
ImplicitContainer<T> clear_devices
Whether or not to clear the device field for an `Operation` or `Tensor` during export.
ImplicitContainer<T> clear_extraneous_savers
Remove any Saver-related information from the graph (both Save/Restore ops and SaverDefs) that are not associated with this Saver.
ImplicitContainer<T> strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
ImplicitContainer<T> save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of filename and with `_debug` added before the file extension.
Returns
object
A `MetaGraphDef` proto.

void recover_last_checkpoints(IEnumerable<object> checkpoint_paths)

Recovers the internal saver state after a crash.

This method is useful for recovering the "self._last_checkpoints" state.

Globs for the checkpoints pointed to by `checkpoint_paths`. If the files exist, use their mtime as the checkpoint timestamp.
Parameters
IEnumerable<object> checkpoint_paths
a list of checkpoint paths.

object recover_last_checkpoints_dyn(object checkpoint_paths)

Recovers the internal saver state after a crash.

This method is useful for recovering the "self._last_checkpoints" state.

Globs for the checkpoints pointed to by `checkpoint_paths`. If the files exist, use their mtime as the checkpoint timestamp.
Parameters
object checkpoint_paths
a list of checkpoint paths.

void restore(_MonitoredSession sess, string save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
_MonitoredSession sess
A `Session` to use to restore the parameters. None in eager mode.
string save_path
Path where parameters were previously saved.

void restore(_MonitoredSession sess, IGraphNodeBase save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
_MonitoredSession sess
A `Session` to use to restore the parameters. None in eager mode.
IGraphNodeBase save_path
Path where parameters were previously saved.

void restore(_MonitoredSession sess, IEnumerable<object> save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
_MonitoredSession sess
A `Session` to use to restore the parameters. None in eager mode.
IEnumerable<object> save_path
Path where parameters were previously saved.

void restore(_MonitoredSession sess, Byte[] save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
_MonitoredSession sess
A `Session` to use to restore the parameters. None in eager mode.
Byte[] save_path
Path where parameters were previously saved.

void restore(WrappedFunction sess, string save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
WrappedFunction sess
A `Session` to use to restore the parameters. None in eager mode.
string save_path
Path where parameters were previously saved.

void restore(WrappedFunction sess, IGraphNodeBase save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
WrappedFunction sess
A `Session` to use to restore the parameters. None in eager mode.
IGraphNodeBase save_path
Path where parameters were previously saved.

void restore(WrappedFunction sess, IEnumerable<object> save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
WrappedFunction sess
A `Session` to use to restore the parameters. None in eager mode.
IEnumerable<object> save_path
Path where parameters were previously saved.

void restore(WrappedFunction sess, Byte[] save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
WrappedFunction sess
A `Session` to use to restore the parameters. None in eager mode.
Byte[] save_path
Path where parameters were previously saved.

void restore(BaseSession sess, string save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
BaseSession sess
A `Session` to use to restore the parameters. None in eager mode.
string save_path
Path where parameters were previously saved.

void restore(BaseSession sess, IGraphNodeBase save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
BaseSession sess
A `Session` to use to restore the parameters. None in eager mode.
IGraphNodeBase save_path
Path where parameters were previously saved.

void restore(BaseSession sess, IEnumerable<object> save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
BaseSession sess
A `Session` to use to restore the parameters. None in eager mode.
IEnumerable<object> save_path
Path where parameters were previously saved.

void restore(BaseSession sess, Byte[] save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
BaseSession sess
A `Session` to use to restore the parameters. None in eager mode.
Byte[] save_path
Path where parameters were previously saved.

object restore_dyn(object sess, object save_path)

Restores previously saved variables.

This method runs the ops added by the constructor for restoring variables. It requires a session in which the graph was launched. The variables to restore do not have to have been initialized, as restoring is itself a way to initialize variables.

The `save_path` argument is typically a value previously returned from a `save()` call, or a call to `latest_checkpoint()`.
Parameters
object sess
A `Session` to use to restore the parameters. None in eager mode.
object save_path
Path where parameters were previously saved.

object save(_WrappedSession sess, string save_path, IGraphNodeBase global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
_WrappedSession sess
A Session to use to save the variables.
string save_path
String. Prefix of filenames created for the checkpoint.
IGraphNodeBase global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save(_WrappedSession sess, string save_path, int global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
_WrappedSession sess
A Session to use to save the variables.
string save_path
String. Prefix of filenames created for the checkpoint.
int global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save(_WrappedSession sess, Byte[] save_path, IGraphNodeBase global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
_WrappedSession sess
A Session to use to save the variables.
Byte[] save_path
String. Prefix of filenames created for the checkpoint.
IGraphNodeBase global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save(_WrappedSession sess, Byte[] save_path, int global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
_WrappedSession sess
A Session to use to save the variables.
Byte[] save_path
String. Prefix of filenames created for the checkpoint.
int global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save(BaseSession sess, string save_path, IGraphNodeBase global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
BaseSession sess
A Session to use to save the variables.
string save_path
String. Prefix of filenames created for the checkpoint.
IGraphNodeBase global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save(BaseSession sess, string save_path, int global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
BaseSession sess
A Session to use to save the variables.
string save_path
String. Prefix of filenames created for the checkpoint.
int global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save(BaseSession sess, Byte[] save_path, IGraphNodeBase global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
BaseSession sess
A Session to use to save the variables.
Byte[] save_path
String. Prefix of filenames created for the checkpoint.
IGraphNodeBase global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save(BaseSession sess, Byte[] save_path, int global_step, string latest_filename, string meta_graph_suffix, bool write_meta_graph, bool write_state, bool strip_default_attrs, bool save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
BaseSession sess
A Session to use to save the variables.
Byte[] save_path
String. Prefix of filenames created for the checkpoint.
int global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
string latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
string meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
bool write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
bool write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
bool strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
bool save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

object save_dyn(object sess, object save_path, object global_step, object latest_filename, ImplicitContainer<T> meta_graph_suffix, ImplicitContainer<T> write_meta_graph, ImplicitContainer<T> write_state, ImplicitContainer<T> strip_default_attrs, ImplicitContainer<T> save_debug_info)

Saves variables.

This method runs the ops added by the constructor for saving variables. It requires a session in which the graph was launched. The variables to save must also have been initialized.

The method returns the path prefix of the newly created checkpoint files. This string can be passed directly to a call to `restore()`.
Parameters
object sess
A Session to use to save the variables.
object save_path
String. Prefix of filenames created for the checkpoint.
object global_step
If provided the global step number is appended to `save_path` to create the checkpoint filenames. The optional argument can be a `Tensor`, a `Tensor` name or an integer.
object latest_filename
Optional name for the protocol buffer file that will contains the list of most recent checkpoints. That file, kept in the same directory as the checkpoint files, is automatically managed by the saver to keep track of recent checkpoints. Defaults to 'checkpoint'.
ImplicitContainer<T> meta_graph_suffix
Suffix for `MetaGraphDef` file. Defaults to 'meta'.
ImplicitContainer<T> write_meta_graph
`Boolean` indicating whether or not to write the meta graph file.
ImplicitContainer<T> write_state
`Boolean` indicating whether or not to write the `CheckpointStateProto`.
ImplicitContainer<T> strip_default_attrs
Boolean. If `True`, default-valued attributes will be removed from the NodeDefs. For a detailed guide, see [Stripping Default-Valued Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes).
ImplicitContainer<T> save_debug_info
If `True`, save the GraphDebugInfo to a separate file, which in the same directory of save_path and with `_debug` added before the file extension. This is only enabled when `write_meta_graph` is `True`
Returns
object
A string: path prefix used for the checkpoint files. If the saver is sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' is the number of shards created. If the saver is empty, returns None.

void set_last_checkpoints_(IEnumerable<object> last_checkpoints)

object set_last_checkpoints__dyn(object last_checkpoints)

void set_last_checkpoints_with_time(IEnumerable<ValueTuple<object, object>> last_checkpoints_with_time)

Sets the list of old checkpoint filenames and timestamps.
Parameters
IEnumerable<ValueTuple<object, object>> last_checkpoints_with_time
A list of tuples of checkpoint filenames and timestamps.

object set_last_checkpoints_with_time_dyn(object last_checkpoints_with_time)

Sets the list of old checkpoint filenames and timestamps.
Parameters
object last_checkpoints_with_time
A list of tuples of checkpoint filenames and timestamps.

Public static methods

Saver from_proto(object saver_def, object import_scope)

Returns a `Saver` object created from `saver_def`.
Parameters
object saver_def
a `SaverDef` protocol buffer.
object import_scope
Optional `string`. Name scope to use.
Returns
Saver
A `Saver` built from saver_def.

object from_proto_dyn(object saver_def, object import_scope)

Returns a `Saver` object created from `saver_def`.
Parameters
object saver_def
a `SaverDef` protocol buffer.
object import_scope
Optional `string`. Name scope to use.
Returns
object
A `Saver` built from saver_def.

Saver NewDyn(object var_list, ImplicitContainer<T> reshape, ImplicitContainer<T> sharded, ImplicitContainer<T> max_to_keep, ImplicitContainer<T> keep_checkpoint_every_n_hours, object name, ImplicitContainer<T> restore_sequentially, object saver_def, object builder, ImplicitContainer<T> defer_build, ImplicitContainer<T> allow_empty, ImplicitContainer<T> write_version, ImplicitContainer<T> pad_step_number, ImplicitContainer<T> save_relative_paths, object filename)

Creates a `Saver`.

The constructor adds ops to save and restore variables.

`var_list` specifies the variables that will be saved and restored. It can be passed as a `dict` or a list:

* A `dict` of names to variables: The keys are the names that will be used to save or restore the variables in the checkpoint files. * A list of variables: The variables will be keyed with their op name in the checkpoint files. Note: the newer `AutoTrackable` API is not supported by `Saver`. In this case, the tf.train.Checkpoint class should be used.

The optional `reshape` argument, if `True`, allows restoring a variable from a save file where the variable had a different shape, but the same number of elements and type. This is useful if you have reshaped a variable and want to reload it from an older checkpoint.

The optional `sharded` argument, if `True`, instructs the saver to shard checkpoints per device.
Parameters
object var_list
A list of `Variable`/`SaveableObject`, or a dictionary mapping names to `SaveableObject`s. If `None`, defaults to the list of all saveable objects.
ImplicitContainer<T> reshape
If `True`, allows restoring parameters from a checkpoint where the variables have a different shape.
ImplicitContainer<T> sharded
If `True`, shard the checkpoints, one per device.
ImplicitContainer<T> max_to_keep
Maximum number of recent checkpoints to keep. Defaults to 5.
ImplicitContainer<T> keep_checkpoint_every_n_hours
How often to keep checkpoints. Defaults to 10,000 hours.
object name
String. Optional name to use as a prefix when adding operations.
ImplicitContainer<T> restore_sequentially
A `Bool`, which if true, causes restore of different variables to happen sequentially within each device. This can lower memory usage when restoring very large models.
object saver_def
Optional `SaverDef` proto to use instead of running the builder. This is only useful for specialty code that wants to recreate a `Saver` object for a previously built `Graph` that had a `Saver`. The `saver_def` proto should be the one returned by the `as_saver_def()` call of the `Saver` that was created for that `Graph`.
object builder
Optional `SaverBuilder` to use if a `saver_def` was not provided. Defaults to `BulkSaverBuilder()`.
ImplicitContainer<T> defer_build
If `True`, defer adding the save and restore ops to the `build()` call. In that case `build()` should be called before finalizing the graph or using the saver.
ImplicitContainer<T> allow_empty
If `False` (default) raise an error if there are no variables in the graph. Otherwise, construct the saver anyway and make it a no-op.
ImplicitContainer<T> write_version
controls what format to use when saving checkpoints. It also affects certain filepath matching logic. The V2 format is the recommended choice: it is much more optimized than V1 in terms of memory required and latency incurred during restore. Regardless of this flag, the Saver is able to restore from both V2 and V1 checkpoints.
ImplicitContainer<T> pad_step_number
if True, pads the global step number in the checkpoint filepaths to some fixed width (8 by default). This is turned off by default.
ImplicitContainer<T> save_relative_paths
If `True`, will write relative paths to the checkpoint state file. This is needed if the user wants to copy the checkpoint directory and reload from the copied directory.
object filename
If known at graph construction time, filename used for variable loading/saving.
Show Example
v1 = tf.Variable(..., name='v1')
            v2 = tf.Variable(..., name='v2') 

# Pass the variables as a dict: saver = tf.compat.v1.train.Saver({'v1': v1, 'v2': v2})

# Or pass them as a list. saver = tf.compat.v1.train.Saver([v1, v2]) # Passing a list is equivalent to passing a dict with the variable op names # as keys: saver = tf.compat.v1.train.Saver({v.op.name: v for v in [v1, v2]})

Public properties

IList<object> last_checkpoints get;

List of not-yet-deleted checkpoint filenames.

You can pass any of the returned values to `restore()`.

object last_checkpoints_dyn get;

List of not-yet-deleted checkpoint filenames.

You can pass any of the returned values to `restore()`.

object PythonObject get;

Nullable<int> saver_def get; set;