A tf.compat.v1.train.Saver adapter for use when eager execution is enabled. The API, and on-disk format, mimic tf.compat.v1.train.Saver except that no Session is needed. Args: var_list: The list of variables that will be saved and restored. Either a list of `tf.Varia
(self, var_list)
| 123 | """ |
| 124 | |
| 125 | def __init__(self, var_list): |
| 126 | """A tf.compat.v1.train.Saver adapter for use when eager execution is enabled. |
| 127 | |
| 128 | The API, and on-disk format, mimic tf.compat.v1.train.Saver except that no |
| 129 | Session is needed. |
| 130 | |
| 131 | Args: |
| 132 | var_list: The list of variables that will be saved and restored. Either a |
| 133 | list of `tf.Variable` objects, or a dictionary mapping names to |
| 134 | `tf.Variable` objects. |
| 135 | |
| 136 | Raises: |
| 137 | RuntimeError: if invoked when eager execution has not been enabled. |
| 138 | """ |
| 139 | if not context.executing_eagerly(): |
| 140 | raise RuntimeError("tfe.Saver can only be used when eager " |
| 141 | "execution is enabled. Use tf.train.Saver when " |
| 142 | "building graphs.") |
| 143 | self._saver = _saver.Saver(var_list=var_list) |
| 144 | |
| 145 | def save(self, file_prefix, global_step=None): |
| 146 | """Saves variables. |
nothing calls this directly
no test coverage detected