tf.contrib.eager.restore_variables_on_create
Stay organized with collections
Save and categorize content based on your preferences.
ContextManager that restores variables on creation.
@contextlib.contextmanager
tf.contrib.eager.restore_variables_on_create(
save_path, map_func=None
)
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(
tf.train.latest_checkpoint(checkpoint_dir)):
Args |
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.
|
Yields:
Nothing.
Raises |
NotFoundError
|
If the variable is not found in checkpoint.
|
ValueError
|
If not used in eager mode or map_func is not callable.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.contrib.eager.restore_variables_on_create\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/eager/python/saver.py#L47-L113) |\n\nContextManager that restores variables on creation. \n\n @contextlib.contextmanager\n tf.contrib.eager.restore_variables_on_create(\n save_path, map_func=None\n )\n\nWhen save_path is None (e.g. No checkpoint), does nothing.\nOtherwise, it preloads all values from checkpoint. When the\ncorresponding variable is first created, it assigns the checkpoint\nvalue to the variable.\n\u003e\n\u003e with restore_variables_on_create(\n\u003e tf.train.latest_checkpoint(checkpoint_dir)):\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `save_path` | The checkpoint file prefix. |\n| `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. |\n\n\u003cbr /\u003e\n\n#### Yields:\n\nNothing.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-----------------|--------------------------------------------------------|\n| `NotFoundError` | If the variable is not found in checkpoint. |\n| `ValueError` | If not used in eager mode or map_func is not callable. |\n\n\u003cbr /\u003e"]]