Skip to content

How does Module.setup() in Flax relate to build() in TF2 Keras? #1058

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

You must be logged in to vote

Answer from @levskaya:

the shape parameters to setup are meant to come from the dataclass attributes. Since by default submodules are usually lazy themselves, they can init their parameters once __call__'d with access to more shape info. If you need to create a -variable- in setup then you have to provide the shape info via attributes.

Replies: 1 comment

Comment options

marcvanzee
Mar 1, 2021
Maintainer Author

You must be logged in to vote
0 replies
Answer selected by marcvanzee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant