How to exclude submodule's parameters for a outer module?

I’m implementing a module based on the paper “Emergence of Invariance and Disentanglement in Deep Representations”, and sample parameters of a base module from a given distribution. So I have to convert all parameters of the base module into Intermediate variables instead of module parameters.

But if I create a base module as a submodule in the outer module, its paramerters will be included into the result of parameters() method automatically. How to exclude submodule’s parameters?

1 Like

Same question here. Check this how-to-exclude-parameters-from-model. Wrap it in a list can solve but also will lose effects when using something like to("cuda").

I knew it, and was trying to find a simpler way, but I finally used it.