MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / restore

Method restore

tensorflow/python/training/tracking/util.py:1168–1275  ·  view source on GitHub ↗

Restore a training checkpoint. Restores `root_trackable` and any objects that it tracks (transitive). Either assigns values immediately if variables to restore have been created already, or defers restoration until the variables are created. Dependencies added to the `root_trackable

(self, save_path)

Source from the content-addressed store, hash-verified

1166 return save_path
1167
1168 def restore(self, save_path):
1169 """Restore a training checkpoint.
1170
1171 Restores `root_trackable` and any objects that it tracks
1172 (transitive). Either assigns values immediately if variables to restore have
1173 been created already, or defers restoration until the variables are
1174 created. Dependencies added to the `root_trackable` passed to the
1175 constructor after this call will be matched if they have a corresponding
1176 object in the checkpoint.
1177
1178 When building a graph, restorations are added to the graph but not run.
1179
1180 To disallow deferred loading, assert immediately that all checkpointed
1181 variables have been matched to variable objects:
1182
1183 ```python
1184 saver = Saver(root)
1185 saver.restore(path).assert_consumed()
1186 ```
1187
1188 An exception will be raised unless every object was matched and its
1189 variables already exist.
1190
1191 When graph building, `assert_consumed()` indicates that all of the restore
1192 ops which will be created for this checkpoint have been created. They can be
1193 run via the `run_restore_ops()` function of the status object:
1194
1195 ```python
1196 saver.restore(path).assert_consumed().run_restore_ops()
1197 ```
1198
1199 If the checkpoint has not been consumed completely, then the list of restore
1200 ops will grow as more objects are added to the dependency graph.
1201
1202 Name-based `tf.compat.v1.train.Saver` checkpoints can be loaded using this
1203 method. There is no deferred loading, and names are used to match
1204 variables. No restore ops are created/run until `run_restore_ops()` or
1205 `initialize_or_restore()` are called on the returned status object, even
1206 when executing eagerly. Re-encode name-based checkpoints using this
1207 object-based `Saver.save` as soon as possible.
1208
1209 Args:
1210 save_path: The path to the checkpoint, as returned by `save` or
1211 `tf.train.latest_checkpoint`. If None (as when there is no latest
1212 checkpoint for `tf.train.latest_checkpoint` to return), returns an
1213 object which may run initializers for objects in the dependency graph.
1214 If the checkpoint was written by the name-based
1215 `tf.compat.v1.train.Saver`, names are used to match variables.
1216
1217 Returns:
1218 A load status object, which can be used to make assertions about the
1219 status of checkpoint restoration and run initialization/restore ops
1220 (of type `CheckpointLoadStatus`, or `InitializationOnlyStatus` if
1221 `save_path` is `None`).
1222
1223 If `save_path` points to a name-based checkpoint, a `NameBasedSaverStatus`
1224 object is returned which runs restore ops from a name-based saver.
1225 """

Callers 4

_restore_checkpointMethod · 0.95

Calls 15

uidMethod · 0.80
executing_eagerlyMethod · 0.80
list_objectsMethod · 0.80
get_tensorMethod · 0.45
addMethod · 0.45

Tested by 3