Autoencoder
- class colibri.models.autoencoder.Autoencoder(in_channels=1, out_channels=1, features=[32, 64, 128, 256], last_activation='sigmoid', reduce_spatial=False, **kwargs)[source]
Bases:
Module
Autoencoder Model
The autoencoder model is a neural network that is trained to learn a latent representation of the input data. The model is composed of an encoder and a decoder. The encoder compresses the input data into a latent space representation, while the decoder reconstructs the input data from the latent space representation. Usually, the autoencoder model is trained to minimize the reconstruction error between the input data and the reconstructed data as follows:
\[\mathcal{L} = \left\| \mathbf{x}- D(E(\mathbf{x})) \right\|_2^2\]where \(\mathbf{x}\) is the input data and \(\hat{\mathbf{x}} = D(E(\mathbf{x}))\) is the reconstructed data with \(E(\cdot)\) and \(D(\cdot)\) the encoder and decoder networks, respectively.
Implementation based on the formulation of authors in https://dl.acm.org/doi/book/10.5555/3086952
- Parameters:
in_channels (int) – number of input channels
out_channels (int) – number of output channels
features (list, optional) – number of features in each level of the Unet. Defaults to [32, 64, 128, 256].
last_activation (str, optional) – activation function for the last layer. Defaults to ‘sigmoid’.
reduce_spatial (bool) – select if the autoencder reduce spatial dimension
- Returns:
Autoencoder model
- Return type:
torch.nn.Module