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
(self,
sess,
save_path,
global_step=None,
latest_filename=None,
meta_graph_suffix="meta",
write_meta_graph=True,
write_state=True,
strip_default_attrs=False,
save_debug_info=False)
| 1334 | self.set_last_checkpoints_with_time(checkpoints_with_mtimes) |
| 1335 | |
| 1336 | def save(self, |
| 1337 | sess, |
| 1338 | save_path, |
| 1339 | global_step=None, |
| 1340 | latest_filename=None, |
| 1341 | meta_graph_suffix="meta", |
| 1342 | write_meta_graph=True, |
| 1343 | write_state=True, |
| 1344 | strip_default_attrs=False, |
| 1345 | save_debug_info=False): |
| 1346 | # pylint: disable=line-too-long |
| 1347 | """Saves variables. |
| 1348 | |
| 1349 | This method runs the ops added by the constructor for saving variables. |
| 1350 | It requires a session in which the graph was launched. The variables to |
| 1351 | save must also have been initialized. |
| 1352 | |
| 1353 | The method returns the path prefix of the newly created checkpoint files. |
| 1354 | This string can be passed directly to a call to `restore()`. |
| 1355 | |
| 1356 | Args: |
| 1357 | sess: A Session to use to save the variables. |
| 1358 | save_path: String. Prefix of filenames created for the checkpoint. |
| 1359 | global_step: If provided the global step number is appended to `save_path` |
| 1360 | to create the checkpoint filenames. The optional argument can be a |
| 1361 | `Tensor`, a `Tensor` name or an integer. |
| 1362 | latest_filename: Optional name for the protocol buffer file that will |
| 1363 | contains the list of most recent checkpoints. That file, kept in the |
| 1364 | same directory as the checkpoint files, is automatically managed by the |
| 1365 | saver to keep track of recent checkpoints. Defaults to 'checkpoint'. |
| 1366 | meta_graph_suffix: Suffix for `MetaGraphDef` file. Defaults to 'meta'. |
| 1367 | write_meta_graph: `Boolean` indicating whether or not to write the meta |
| 1368 | graph file. |
| 1369 | write_state: `Boolean` indicating whether or not to write the |
| 1370 | `CheckpointStateProto`. |
| 1371 | strip_default_attrs: Boolean. If `True`, default-valued attributes will be |
| 1372 | removed from the NodeDefs. For a detailed guide, see |
| 1373 | [Stripping Default-Valued |
| 1374 | Attributes](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/saved_model/README.md#stripping-default-valued-attributes). |
| 1375 | save_debug_info: If `True`, save the GraphDebugInfo to a separate file, |
| 1376 | which in the same directory of save_path and with `_debug` added before |
| 1377 | the file extension. This is only enabled when `write_meta_graph` is |
| 1378 | `True` |
| 1379 | |
| 1380 | Returns: |
| 1381 | A string: path prefix used for the checkpoint files. If the saver is |
| 1382 | sharded, this string ends with: '-?????-of-nnnnn' where 'nnnnn' |
| 1383 | is the number of shards created. |
| 1384 | If the saver is empty, returns None. |
| 1385 | |
| 1386 | Raises: |
| 1387 | TypeError: If `sess` is not a `Session`. |
| 1388 | ValueError: If `latest_filename` contains path components, or if it |
| 1389 | collides with `save_path`. |
| 1390 | RuntimeError: If save and restore ops weren't built. |
| 1391 | """ |
| 1392 | # pylint: enable=line-too-long |
| 1393 | if not self._is_built and not context.executing_eagerly(): |