Open avital opened 3 years ago
@marcvanzee will be investigating this.
A few guiding questions:
Just noticing this issue for the first time... I've seen similarly weird issues with Mixins and Flax resolved in the past by simply changing the order of the multiple inheritance - e.g. class Reduce(nn.Module, ReduceMixin):
to put nn.Module
first. I'm not 100% sure this is the same kind of issue that I've seen before w. mixins, but I'd certainly be curious if that would have fixed the issue...
I was playing around with mixins to see how they interact with Module
.
Based on these experiments the only insight I see is: don't define scope-dependent operations (compact
, self.param
/variable
) in inside mixins as their methods will not be wrapped appropriately. Not sure if there is a way to properly wrap mixin methods in __init_subclass__
, either _get_local_method_names
is not detecting them or they are not available when __init_subclass__
is called.
I'm also having trouble with mixins. I suggest adding some documentation about how to make flax modules play well with mixins.
Discussed in https://github.com/google/flax/discussions/1390
Error Message
``` Traceback (most recent call last): File "/Users/sauravmaheshkar/github/protein_bert/test.py", line 21, in