rbnet.util.ConstrainedModuleMixin
- class rbnet.util.ConstrainedModuleMixin[source]
Bases:
objectA mixin class for modules with constraints to work cooperatively. Calling
enforce_constraints()will recursively try to call this method on child modules.Typical usage would be to call
enforce_constraints()on the top-level parent module before the forward pass and/or after an optimisation step.See
Probfor an example.Public Methods:
enforce_constraints([recurse])Enforce constraints for module parameters and child modules.
remap(param[, _top_level, prefix])
- enforce_constraints(recurse=True)[source]
Enforce constraints for module parameters and child modules.
If modules have constrained parameters, they should override this method to enforce these constraints. If they also have child modules and
recurse=True, they should additionally callsuper().enforce_constraints()to recursively propagate the call.