Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Checkpoint adapter for TPU Embeddings. #753

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions tf_keras/optimizers/legacy/optimizer_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -1540,7 +1540,8 @@ def _restore_slot_variable(self, slot_name, variable, slot_variable):
checkpoint_position.restore(slot_variable)

def _create_or_restore_slot_variable(
self, slot_variable_position, slot_name, variable
self, slot_variable_position, slot_name, variable,
slot_variable_shape=None
):
"""Returns the slot variable that should have a value restored into it.

Expand All @@ -1563,6 +1564,8 @@ def _create_or_restore_slot_variable(
indicating the slot variable `Trackable` object to be restored.
slot_name: The name of this `Optimizer`'s slot to restore into.
variable: The variable object this slot is being created for.
slot_variable_shape: (Optional) Shape of the required slot variable.
When not provided, the shape is same as the value in checkpoint.

Returns:
A slot variable that should have a value restored into it, or None if
Expand Down Expand Up @@ -1602,7 +1605,7 @@ def _create_or_restore_slot_variable(
var=variable,
initializer=initializer,
slot_name=slot_name,
shape=slot_variable_position.value_shape(),
shape=slot_variable_position.value_shape() if slot_variable_shape is None else slot_variable_shape,
)
# Slot variables are not owned by any one object (because we don't
# want to save the slot variable if the optimizer is saved without
Expand Down
Loading