Skip to content

Fix the Attribute Error in gradient_accumulation_and_microbatching.ipynb example notebook - #1740

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

Fix the Attribute Error in gradient_accumulation_and_microbatching.ipynb example notebook#1740
rajasekharporeddy wants to merge 1 commit into
google-deepmind:mainfrom
rajasekharporeddy:summary

Conversation

@rajasekharporeddy

Copy link
Copy Markdown
Collaborator

Currently the gradient_accumulation_and_microbatching.ipynb example notebook fails with an attribute error at final cell due to the usage ".get_value()" on JAX Array object.

--------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_2474/647667932.py in <cell line: 0>()
      1 # This shows the norm for the gradient of the embedding layer per example.
      2 # High uniformity of the norm values is encouraging.
----> 3 aux.metrics['embedding']['embedding'].get_value()

/usr/local/lib/python3.12/dist-packages/flax/nnx/variablelib.py in __getattr__(self, name)
    279     if name in object.__getattribute__(self, '_var_metadata'):
    280       return self._var_metadata[name]
--> 281     return getattr(self.raw_value, name)
    282
    283   def __setattr__(self, name: str, value: tp.Any):

AttributeError: 'jaxlib._jax.ArrayImpl' object has no attribute 'get_value'

This is fixed by using .value instead of .get_value() in the final cell to display the out.

Repro Colab notebook: gist

Working notebook: gist

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