tf.contrib.eager.restore_variables_on_create

tf.contrib.eager.restore_variables_on_create(
    *args,
    **kwds
)

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(
    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.