TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

tf.contrib.eager.restore_variables_on_create

ContextManager that restores variables on creation.

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

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.