You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Its common for users to want to get access to a submodule defined in setup from the outside, however they soon find out that .setup doesn't run upon construction and then they have to figure out how to get access to this. E.g:
Our current solution as proposed in the Transfer Learning guide is to use nn.apply with a helper function that extracts the needed objects (since the Module is bounded at this point):
defextract_submodule(module):
submodule=module.submodule.clone() # clone to avoid leakagesubmodule_variables=module.submodule.variablesreturnsubmodule, submodule_variablessubmodule, submodule_variables=nn.apply(extract_submodule, module)(variables)
Since this pattern is both common and has some rough edges (users need to remember to use .clone which is really more of an internal API) it would be good to create a helper function to automate this use case.
The text was updated successfully, but these errors were encountered:
Its common for users to want to get access to a submodule defined in
setup
from the outside, however they soon find out that.setup
doesn't run upon construction and then they have to figure out how to get access to this. E.g:Our current solution as proposed in the Transfer Learning guide is to use
nn.apply
with a helper function that extracts the needed objects (since the Module is bounded at this point):Since this pattern is both common and has some rough edges (users need to remember to use
.clone
which is really more of an internal API) it would be good to create a helper function to automate this use case.The text was updated successfully, but these errors were encountered: