Skip to content

Multiple Inheritance -> doesn't recognize as Module throws ValueError: parent must be None, Module or Scope #1390

Answered by marcvanzee
SauravMaheshkar asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @SauravMaheshkar, Flax Modules are special kinds of dataclasses in the sense that they will attach parent and name attributes automatically. The parent attribute is usually assigned automatically: it is set to the parent Module, or set to None if this is the top-level module. However, if you provide Modules with a string argument, the parent attribute will be set to the string value. Here is a minimal example:

class Bar(nn.Module):
  @nn.compact
  def __call__(self, x):
    pass
>>> Bar('test')
...
ValueError: parent must be None, Module or Scope

In your case, in ProteinBert.setup(), you initialize Reduce as follows: Reduce("b n d -> b d", "mean"). You intend to call the constructor of

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@SauravMaheshkar
Comment options

Answer selected by SauravMaheshkar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants