Skip to content

Commit 96a0845

Browse files
Clarify docstrings that mention assert_consumed()
In response to discussions in tensorflow/tensorflow#52346 * Rename delay / delayed restorations to defer / deferred restorations to be consistent * Clarify that "no more assignments" means no more deferred restorations. * Remove .assert_consumed() from unrelated examples. Because of deferred restorations, calling .assert_consumed() immediately after restore() is likely to fail. There's also no need to recommend calling assert_consumed() after every restore(), as assert_consumed() is meant to guard against unexpected overwrites when fine-tuning a model, which isn't common. PiperOrigin-RevId: 417461429
1 parent d0f50c7 commit 96a0845

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

site/en/guide/checkpoint.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@
423423
"\n",
424424
"The optimizer is in red, regular variables are in blue, and the optimizer slot variables are in orange. The other nodes—for example, representing the `tf.train.Checkpoint`—are in black.\n",
425425
"\n",
426-
"Slot variables are part of the optimizer's state, but are created for a specific variable. For example the `'m'` edges above correspond to momentum, which the Adam optimizer tracks for each variable. Slot variables are only saved in a checkpoint if the variable and the optimizer would both be saved, thus the dashed edges."
426+
"Slot variables are part of the optimizer's state, but are created for a specific variable. For example, the `'m'` edges above correspond to momentum, which the Adam optimizer tracks for each variable. Slot variables are only saved in a checkpoint if the variable and the optimizer would both be saved, thus the dashed edges."
427427
]
428428
},
429429
{
@@ -491,11 +491,11 @@
491491
"id": "KCcmJ-2j9RUP"
492492
},
493493
"source": [
494-
"### Delayed restorations\n",
494+
"### Deferred restorations\n",
495495
"\n",
496-
"`Layer` objects in TensorFlow may delay the creation of variables to their first call, when input shapes are available. For example the shape of a `Dense` layer's kernel depends on both the layer's input and output shapes, and so the output shape required as a constructor argument is not enough information to create the variable on its own. Since calling a `Layer` also reads the variable's value, a restore must happen between the variable's creation and its first use.\n",
496+
"`Layer` objects in TensorFlow may defer the creation of variables to their first call, when input shapes are available. For example, the shape of a `Dense` layer's kernel depends on both the layer's input and output shapes, and so the output shape required as a constructor argument is not enough information to create the variable on its own. Since calling a `Layer` also reads the variable's value, a restore must happen between the variable's creation and its first use.\n",
497497
"\n",
498-
"To support this idiom, `tf.train.Checkpoint` queues restores which don't yet have a matching variable."
498+
"To support this idiom, `tf.train.Checkpoint` defers restores which don't yet have a matching variable."
499499
]
500500
},
501501
{
@@ -506,10 +506,10 @@
506506
},
507507
"outputs": [],
508508
"source": [
509-
"delayed_restore = tf.Variable(tf.zeros([1, 5]))\n",
510-
"print(delayed_restore.numpy()) # Not restored; still zeros\n",
511-
"fake_layer.kernel = delayed_restore\n",
512-
"print(delayed_restore.numpy()) # Restored"
509+
"deferred_restore = tf.Variable(tf.zeros([1, 5]))\n",
510+
"print(deferred_restore.numpy()) # Not restored; still zeros\n",
511+
"fake_layer.kernel = deferred_restore\n",
512+
"print(deferred_restore.numpy()) # Restored"
513513
]
514514
},
515515
{

site/en/guide/migrate/migrating_checkpoints.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@
834834
"\n",
835835
"**TF2 checkpoints work with Keras's `build()` step**\n",
836836
"\n",
837-
"`tf.train.Checkpoint.restore` has a mechanism called *delayed restoration* which\n",
837+
"`tf.train.Checkpoint.restore` has a mechanism called *deferred restoration* which\n",
838838
"allows `tf.Module` and Keras objects to store variable values if the variable has not yet been created. This allows *initialized* models to load weights and *build* after.\n",
839839
"\n",
840840
"```\n",

0 commit comments

Comments
 (0)