What is the difference between Module.param() and Module.variable()? #919
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
In code:
So
We create a new PRNG sequence inline with If you only need it once in the initializer, you can do this:
|
Beta Was this translation helpful? Give feedback.
Module.param()
is a special case ofModule.variable
that assumes 3 things:init()
fn accepts a PRNGKey as the first arg (in addition to any additionally provided ones)params
In code:
So
self.param
is simply a a convenience, because 95% or more of the time user want to define NN parameters, but theself.variable
call lets you do whatever yo…