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

fix(optimizer): Bug: Variable set to trainable to false still updating embedding #263

Merged
merged 1 commit into from
Jul 18, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ def apply_grad_to_update_var(var, grad):
else:
return update_op
else:
if not var.params.trainable:
return control_flow_ops.no_op()

with ops.colocate_with(None, ignore_existing=True):
_slots = [self.get_slot(var, _s) for _s in self.get_slot_names()]
var._track_optimizer_slots(_slots)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ def update_op(self, optimizer, g):
# pylint: disable=protected-access
# for better convergence:

if not self._v.params.trainable:
return control_flow_ops.no_op()

with ops.colocate_with(None, ignore_existing=True):
_slots = [
optimizer.get_slot(self._v, _s) for _s in optimizer.get_slot_names()
Expand Down