How does Module.setup() in Flax relate to build() in TF2 Keras? #1058
-
(Original question from Han Zhang) The TF2 Keras API has a
I originally thought it would be similar to build function in TF2, however, I could not get the input shape using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Answer from @levskaya: the shape parameters to |
Beta Was this translation helpful? Give feedback.
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.