Skip to content

Fix AttributeError in Sharpness-Aware Minimization (SAM) example notebook by using _replace for NamedTuple - #1742

Open
rajasekharporeddy wants to merge 1 commit into
google-deepmind:mainfrom
rajasekharporeddy:sam
Open

Fix AttributeError in Sharpness-Aware Minimization (SAM) example notebook by using _replace for NamedTuple#1742
rajasekharporeddy wants to merge 1 commit into
google-deepmind:mainfrom
rajasekharporeddy:sam

Conversation

@rajasekharporeddy

Copy link
Copy Markdown
Collaborator

Issue Description:

Running the examples/sam.ipynb notebook currently fails with an

AttributeError: 'Store' object has no attribute 'replace'

during the training loops. This is because the Store class is defined as a typing.NamedTuple. In Python, the standard method to create a new instance of a NamedTuple with updated fields is _replace(), not replace().

Fix:

This PR fixes the issue by updating store.replace(...) to store._replace(...) in both instances of the make_step function within the notebook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant