Skip to content

chore: Fix error on flax 0.12.0 #228

@emergenz

Description

@emergenz
ValueError: Found unexpected Arrays on value of type <class 'list'> in static attribute 'blocks' of Pytree type '<class 'utils.nn.STTransformer'>'. This is an error starting from Flax version 0.12.0.
Consider one of the following options:

1. If the attribute is meant to be static, either remove the Array value or wrap it in a static container.
2. Wrap the value with nnx.data on assignment:

  _.blocks = nnx.data(...)

3. Annotate the class attribute with nnx.Data:

  class STTransformer(Module):
    blocks: nnx.Data[list]

4. If the container is a list or dict, try using nnx.List(...) or nnx.Dict(...) instead.
5. Disable pytree for this class:

  class STTransformer(Module, pytree=False):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions