LION.models.torch_model¶
Classes
|
A plain torch module as a LIONmodel: |
Functions
|
How instances of |
- class LION.models.torch_model.TorchModel(module_class, arguments=None, model_parameters=None, noise_level=None)[source]¶
Bases:
LIONmodelA plain torch module as a LIONmodel:
module_class(**arguments).The class and its arguments are recorded, so the model can be saved, loaded and made again like any LIONmodel, and used where LION needs one (e.g. as GSD’s denoiser):
model = TorchModel(MyNet, {"channels": 32}) model.save("my_net") model = TorchModel.load("my_net", allow=["my_package."])module_classmust be importable where the model is loaded: a class fromtorch.nnor LION loads as it is; one from your own module needsallow=["your_module."]when loading (one defined in the script that loads it:allow=["__main__."]).argumentsmust be values a spec can hold (numbers, strings, lists, dicts, LION parameters, …), not tensors.model_parameters: LION’s own (model_input_type, IMAGE by default).noise_level: how the module takes the noise level, for a denoiser: “channel” (an extra input channel, constant at the noise level) or the name of its keyword argument (e.g. “sigma”). None: asnoise_level_inputfinds (NOISE_LEVEL, then the module’sforward). The model is called as every LION model taking a noise level is,model(x, noise_level=...), and gives it to the module that way. Other arguments go to the module as they are.Initialize internal Module state, shared by both nn.Module and ScriptModule.
- static default_parameters()[source]¶
LION’s own parameters:
model_input_typeIMAGE. The module’s are itsarguments.