Encoder-Decoder Networks#
Classes#
- class BaseEncoder(save_num, states_dir, net, *, overwrite=False, mix_precision=False, learning_rate=0.001, description='', verbose='epoch', classes=None, loss_func=None, transform=None, in_transform=None, optimiser_kwargs=None, scheduler_kwargs=None)[source]#
Bases:
BaseArchitectureBase encoder architecture for predicting low-dimensional data from high-dimensional inputs.
- Attributes:
- description
str Description of the architecture
- version
str Version of the architecture
- losses
tuple[list[LossCT],list[LossCT]] Architecture training and validation losses as a float or dictionary of losses for each loss function
- transforms
dict[str,list[BaseTransform] |BaseTransform|NoneType] Keys for the output data from predict and corresponding transforms
- idxs: ndarray | None
Training data indices with shape (N) and type int, where N is the number of elements in the training dataset
- classes
Tensor|NoneType Unique classes of shape (C) and type int/float, where C is the number of classes
- optimiser
Optimizer Architecture optimiser
- scheduler
LRScheduler Optimiser scheduler
- net
BaseNetwork Neural network
- description
- Parameters:
- save_num
int|str File number or name to save the architecture
- states_dir
str Directory to save the architecture
- net
Module|BaseNetwork Network to predict low-dimensional data
- overwritebool,
Optional If saving can overwrite an existing save file, if True and file with the same name exists, an error will be raised, default = False
- mix_precision: bool, Optional
If mixed precision should be used, default = False
- learning_rate
float,Optional Optimiser initial learning rate, if None, no optimiser or scheduler will be set, default = 1e-3
- description
str,Optional Description of the architecture training
- verbose{‘full’, ‘progress’,
NoneType} If details about epoch should be printed (‘full’), just a progress bar (‘progress’), or nothing (None)
- classes
Tensor,Optional Unique classes of shape (C) and type int/float, where C is the number of classes, if using class classification
- loss_func
BaseLoss|NoneType,Optional Loss function for the encoder, if None MSELoss will be used if classes is None, else CrossEntropyLoss will be used
- transform
BaseTransform,Optional Transformation of the low-dimensional data
- in_transform
BaseTransform,Optional Transformation for the input data
- optimiser_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_optimiser
- scheduler_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_scheduler
- save_num
- extra_repr()[source]#
Additional representation of the architecture.
- Returns:
strArchitecture specific representation
- to(*args, **kwargs)[source]#
See
torch.nn.Module.to().
- class Autoencoder(save_num, states_dir, net, *, overwrite=False, mix_precision=False, learning_rate=0.001, description='', verbose='epoch', transform=None, latent_transform=None, optimiser_kwargs=None, scheduler_kwargs=None)[source]#
Bases:
BaseArchitectureArchitecture handler for autoencoder type architectures.
- Attributes:
- description
str Description of the architecture
- losses
tuple[list[LossCT],list[LossCT]] Architecture training and validation losses as a float or dictionary of losses for each loss function
- transforms
dict[str,list[BaseTransform] |BaseTransform|NoneType] Keys for the output data from predict and corresponding transforms
- idxs: ndarray | None
Training data indices with shape (N) and type int, where N is the number of elements in the training dataset
- optimiser
Optimizer Architecture optimiser
- scheduler
LRScheduler Optimiser scheduler
- net
BaseNetwork Neural network
- reconstruct_func
BaseLoss Loss function for the reconstruction loss
- latent_func
BaseLoss Loss function for the latent loss
- description
- Parameters:
- save_num
int|str File number or name to save the architecture
- states_dir
str Directory to save the architecture
- net
Module|BaseNetwork Network to predict low-dimensional data
- overwritebool,
Optional If saving can overwrite an existing save file, if True and file with the same name exists, an error will be raised, default = False
- mix_precision: bool, Optional
If mixed precision should be used, default = False
- learning_rate
float,Optional Optimiser initial learning rate, default = 1e-3
- description
str,Optional Description of the architecture training
- verbose{‘full’, ‘progress’,
NoneType} If details about epoch should be printed (‘full’), just a progress bar (‘progress’), or nothing (None)
- transform
BaseTransform,Optional Transformation applied to the input data
- latent_transform
BaseTransform,Optional Transformation applied to the latent space
- optimiser_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_optimiser
- scheduler_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_scheduler
- save_num
- batch_predict(data, **_)[source]#
Generates predictions for the given data batch.
- Parameters:
- data
TensorListLike Data to generate predictions for of shape (N, …) and type float, where N is the batch size
- data
- Returns:
tuple[NDArrayListLike|NoneType, …]Predictions of shape (N, …) and type float for the given data
- class Decoder(save_num, states_dir, net, *, overwrite=False, mix_precision=False, learning_rate=0.001, description='', verbose='epoch', transform=None, in_transform=None, optimiser_kwargs=None, scheduler_kwargs=None)[source]#
Bases:
BaseArchitectureDecoder architecture for predicting high-dimensional data from low-dimensional inputs.
- Attributes:
- description
str Description of the architecture
- losses
tuple[list[LossCT],list[LossCT]] Architecture training and validation losses as a float or dictionary of losses for each loss function
- transforms
dict[str,list[BaseTransform] |BaseTransform|NoneType] Keys for the output data from predict and corresponding transforms
- loss_func
BaseLoss Loss function for the reconstructions
- idxs: ndarray | None
Training data indices with shape (N) and type int, where N is the number of elements in the training dataset
- optimiser
Optimizer Architecture optimiser
- scheduler
LRScheduler Optimiser scheduler
- net
BaseNetwork Neural network
- description
- Parameters:
- save_num
int|str File number or name to save the architecture
- states_dir
str Directory to save the architecture
- net
Module|BaseNetwork Network to predict low-dimensional data
- overwritebool,
Optional If saving can overwrite an existing save file, if True and file with the same name exists, an error will be raised, default = False
- mix_precision: bool, Optional
If mixed precision should be used, default = False
- learning_rate
float,Optional Optimiser initial learning rate, if None, no optimiser or scheduler will be set, default = 1e-3
- description
str,Optional Description of the architecture
- verbose{‘epoch’, ‘full’, ‘progress’,
NoneType} If details about each epoch should be printed (‘epoch’), details about epoch and epoch progress (full), just total progress (‘progress’), or nothing (None)
- transform
BaseTransform,Optional Transformation of the architecture’s output
- in_transform
BaseTransform,Optional Transformation for the input data
- optimiser_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_optimiser
- scheduler_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_scheduler
- save_num
- class Encoder(save_num, states_dir, net, *, overwrite=False, mix_precision=False, learning_rate=0.001, description='', verbose='epoch', classes=None, loss_func=None, transform=None, in_transform=None, optimiser_kwargs=None, scheduler_kwargs=None)[source]#
Bases:
BaseEncoderEncoder architecture for predicting low-dimensional data from high-dimensional inputs.
- Attributes:
- description
str Description of the architecture
- losses
tuple[list[LossCT],list[LossCT]] Architecture training and validation losses as a float or dictionary of losses for each loss function
- transforms
dict[str,list[BaseTransform] |BaseTransform|NoneType] Keys for the output data from predict and corresponding transforms
- idxs: ndarray | None
Training data indices with shape (N) and type int, where N is the number of elements in the training dataset
- classes
Tensor|NoneType Unique classes of shape (C) and type int/float, where C is the number of classes
- optimiser
Optimizer Architecture optimiser
- scheduler
LRScheduler Optimiser scheduler
- net
BaseNetwork Neural network
- description
- Parameters:
- save_num
int|str File number or name to save the architecture
- states_dir
str Directory to save the architecture
- net
Module|BaseNetwork Network to predict low-dimensional data
- overwritebool,
Optional If saving can overwrite an existing save file, if True and file with the same name exists, an error will be raised, default = False
- mix_precision: bool, Optional
If mixed precision should be used, default = False
- learning_rate
float,Optional Optimiser initial learning rate, if None, no optimiser or scheduler will be set, default = 1e-3
- description
str,Optional Description of the architecture training
- verbose{‘full’, ‘progress’,
NoneType} If details about epoch should be printed (‘full’), just a progress bar (‘progress’), or nothing (None)
- classes
Tensor,Optional Unique classes of shape (C) and type int/float, where C is the number of classes, if using class classification
- loss_func
BaseLoss|NoneType,Optional Loss function for the encoder, if None MSELoss will be used if classes is None, else CrossEntropyLoss will be used
- transform
BaseTransform,Optional Transformation of the low-dimensional data
- in_transform
BaseTransform,Optional Transformation for the input data
- optimiser_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_optimiser
- scheduler_kwargs
dict[str,Any] |NoneType,Optional Optional keyword arguments to pass to init_scheduler
- save_num
- batch_predict(data, **_)[source]#
Generates predictions for the given data.
- Parameters:
- data
TensorListLike Data to generate predictions for of shape (N, …) and type float, where N is the batch size
- data
- Returns:
tuple[NDArrayListLike|NoneType, …]Predictions of shape (N,…) and type float for the given data