View source on GitHub

ContextManager that restores variables on creation.

When save_path is None (e.g. No checkpoint), does nothing. Otherwise, it preloads all values from checkpoint. When the corresponding variable is first created, it assigns the checkpoint value to the variable.

with restore_variables_on_create(

save_path The checkpoint file prefix.
map_func A function that given the variable name as argument and returns a variable name in checkpoint for restore. If None, use the variable with the same name in checkpoint to restore. It's an error that the mapped variable name doesn't exist in checkpoint.



NotFoundError If the variable is not found in checkpoint.
ValueError If not used in eager mode or map_func is not callable.