Inverse Mapping
Defines a module that includes an inverse mapping.
In the typical ECGAN use-case the module would consist of two different mappings: \(G: A \rightarrow B\) and \(Inv: B \rightarrow A\), where \(G\) is a typical generator that maps a given distribution (commonly a normal distribution) \(A\) to some set \(B\). The Inv function is the inverting mapping, essentially tasked with restoring the distribution \(A\) from a given sample of \(B\).
- class ecgan.modules.inverse_mapping.inverse_mapping.InvertibleBaseModule(inv_cfg, module_cfg, seq_len, num_channels, tracker=None)[source]
Bases:
ecgan.modules.base.BaseModule
,ecgan.utils.configurable.Configurable
The abstract base class for inverse mappings.
Every implementation of this class
gets at least a reference to some trained generator module and
must implement an inverse method (
invert
) that restores the input data for the generator module.
- abstract invert(data)[source]
Apply the inverse mapping for the provided data.
Note that the function does not make any assumptions about the gradient and must be wrapped into a torch.no_grad if the gradient is not needed.
- Return type
Tensor
- training_step(batch)[source]
Perform a training step that can be called by a
ecgan.training.trainer.Trainer
class instance.Note that the function does not require training data and the batch is only required to figure out the appropriate batch size.
- Return type
dict
- load(model_reference, load_optim=False)[source]
Load an inverse mapping model.
The modules have to decide to save/load optimizers by themselves.
- Parameters
model_reference (
str
) -- Reference used to load an existing model.load_optim (
bool
) -- Flag to indicate if the optimizer params should be loaded.
- Return type