Skip to content

Instantly share code, notes, and snippets.

@bayerj
Created May 17, 2020 18:27
Show Gist options
  • Save bayerj/96f096c7fb09a7c9b758dabdbca32671 to your computer and use it in GitHub Desktop.
Save bayerj/96f096c7fb09a7c9b758dabdbca32671 to your computer and use it in GitHub Desktop.
In [2]: import flax
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-2-5854b141ca7d> in <module>
----> 1 import flax
~/.virtualenvs/flax2/lib/python3.7/site-packages/flax/__init__.py in <module>
32
33 # Allow `import flax`; `flax.nn.[...]`, and the same for `flax.optim.[...]`
---> 34 from . import nn
35 from . import optim
~/.virtualenvs/flax2/lib/python3.7/site-packages/flax/nn/__init__.py in <module>
20 log_softmax, relu, sigmoid, soft_sign, softmax,
21 softplus, swish, tanh)
---> 22 from .attention import (dot_product_attention, MultiHeadDotProductAttention,
23 SelfAttention)
24 from .base import (Module, Model, Collection, capture_module_outputs,
~/.virtualenvs/flax2/lib/python3.7/site-packages/flax/nn/attention.py in <module>
21
22 from .. import jax_utils
---> 23 from . import base
24 from . import initializers
25 from . import stochastic
~/.virtualenvs/flax2/lib/python3.7/site-packages/flax/nn/base.py in <module>
897
898
--> 899 @struct.dataclass
900 class Model:
901 """A Model contains the model paramaters, state and definition."""
~/.virtualenvs/flax2/lib/python3.7/site-packages/flax/struct.py in dataclass(clz)
74 The new class.
75 """
---> 76 data_clz = dataclasses.dataclass(frozen=True)(clz)
77 meta_fields = []
78 data_fields = []
~/.virtualenvs/flax2/lib/python3.7/site-packages/dataclasses.py in wrap(cls)
948
949 def wrap(cls):
--> 950 return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
951
952 # See if we're being called as @dataclass or @dataclass().
~/.virtualenvs/flax2/lib/python3.7/site-packages/dataclasses.py in _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
799 # we can.
800 cls_fields = [_get_field(cls, name, type)
--> 801 for name, type in cls_annotations.items()]
802 for f in cls_fields:
803 fields[f.name] = f
~/.virtualenvs/flax2/lib/python3.7/site-packages/dataclasses.py in <listcomp>(.0)
799 # we can.
800 cls_fields = [_get_field(cls, name, type)
--> 801 for name, type in cls_annotations.items()]
802 for f in cls_fields:
803 fields[f.name] = f
~/.virtualenvs/flax2/lib/python3.7/site-packages/dataclasses.py in _get_field(cls, a_name, a_type)
657 typing = sys.modules.get('typing')
658 if typing:
--> 659 if (_is_classvar(a_type, typing)
660 or (isinstance(f.type, str)
661 and _is_type(f.type, cls, typing, typing.ClassVar,
~/.virtualenvs/flax2/lib/python3.7/site-packages/dataclasses.py in _is_classvar(a_type, typing)
548 # This test uses a typing internal class, but it's the best way to
549 # test if this is a ClassVar.
--> 550 return type(a_type) is typing._ClassVar
551
552
AttributeError: module 'typing' has no attribute '_ClassVar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment