Models
mlpoppyns.learning.models.model_base
Base model.
Authors:
Alberto Garcia Garcia (garciagarcia@ice.csic.es)
ModelBase
Bases: Module
Base abstract class for all models.
This class serves as a blueprint for creating various neural-network architecture models. It defines the essential methods that all models must implement, ensuring consistency.
Source code in mlpoppyns/learning/models/model_base.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
__str__()
String representation of the model.
This method should provide a human-readable description of the model, including its name and any relevant parameters or characteristics.
Returns:
| Type | Description |
|---|---|
str
|
String representation of the model. |
Source code in mlpoppyns/learning/models/model_base.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
forward(*inputs)
abstractmethod
Forward pass.
Abstract method for the forward pass that must be implemented for each model that derives this class to implement its whole forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Tensor
|
The network inputs. |
()
|
Returns:
| Type | Description |
|---|---|
Tensor
|
The network output tensor after forwarding all layers. |
Source code in mlpoppyns/learning/models/model_base.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
mlpoppyns.learning.models.model_conv
Model for a convolutional neural network.
Authors:
Michele Ronchi (ronchi@ice.csic.es)
Alberto Garcia Garcia (garciagarcia@ice.csic.es)
ModelConv
Bases: ModelBase
A convolutional neural network model
Source code in mlpoppyns/learning/models/model_conv.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
__init__(input_shape, num_parameters=1)
CNN model initialization.
This CNN automatically adapts to the shape of the initial input features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
array
|
Shape of the input batch (C x H x W). |
required |
num_parameters
|
int
|
Number of parameters to predict. |
1
|
Source code in mlpoppyns/learning/models/model_conv.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
convs(x)
Convolution and pooling layers forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the convolution layers. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the convolution and pooling layers. |
Source code in mlpoppyns/learning/models/model_conv.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
forward(x)
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the network. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the network after forwarding all layers. |
Source code in mlpoppyns/learning/models/model_conv.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
mlpoppyns.learning.models.model_conv_sbi
Model for a deeper convolutional neural network used as an embedding network in the sbi framework to compress the input features into a latent vector. The architecture consists of two blocks of convolutional layers, each followed by a max-pooling layer. The final output is flattened and passed through a fully connected layer to produce the latent vector used for inference.
Authors:
Michele Ronchi (ronchi@ice.csic.es)
ModelConvSBI
Bases: ModelBase
A convolutional neural network model with 2 convolutional filters.
Source code in mlpoppyns/learning/models/model_conv_sbi.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
__init__(input_shape, len_output_layer=1)
CNN model initialization.
This CNN automatically adapts to the shape of the initial input features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
array
|
Shape of the input batch (C x H x W). |
required |
len_output_layer
|
int
|
Length of the latent vector. |
1
|
Source code in mlpoppyns/learning/models/model_conv_sbi.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
convs(x)
Convolution and pooling layers forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the convolution layers. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the convolution and pooling layers. |
Source code in mlpoppyns/learning/models/model_conv_sbi.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
forward(x)
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the network. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the network after forwarding all layers. |
Source code in mlpoppyns/learning/models/model_conv_sbi.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
mlpoppyns.learning.models.model_conv_sbi_deep
Model for a deeper convolutional neural network used as an embedding network in the sbi framework to compress the input features into a latent vector. The architecture consists of three blocks of convolutional layers, each followed by a max-pooling layer. The final output is flattened and passed through a fully connected layer to produce the latent vector used for inference.
Authors:
Michele Ronchi (ronchi@ice.csic.es)
ModelConvSBIdeep
Bases: ModelBase
A convolutional neural network model with 4 convolutional filters.
Source code in mlpoppyns/learning/models/model_conv_sbi_deep.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
__init__(input_shape, len_output_layer=1)
CNN model initialization.
This CNN automatically adapts to the shape of the initial input features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
array
|
Shape of the input batch (C x H x W). |
required |
len_output_layer
|
int
|
Length of the latent vector. |
1
|
Source code in mlpoppyns/learning/models/model_conv_sbi_deep.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
convs(x)
Convolution and pooling layers forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the convolution layers. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the convolution and pooling layers. |
Source code in mlpoppyns/learning/models/model_conv_sbi_deep.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
forward(x)
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the network. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the network after forwarding all layers. |
Source code in mlpoppyns/learning/models/model_conv_sbi_deep.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
mlpoppyns.learning.models.model_conv_sbi_shallow
Model for a shallow convolutional neural network used as an embedding network in the sbi framework to compress the input features into a latent vector. The neural network is composed of a single convolutional layer after a max-pool layer, followed by a fully connected layer that will serve as the latent vector.
Authors:
Michele Ronchi (ronchi@ice.csic.es)
Celsa Pardo Araujo (pardo@ice.csic.es)
ModelConvSBIshallow
Bases: ModelBase
A convolutional neural network model with 1 convolutional filters.
Source code in mlpoppyns/learning/models/model_conv_sbi_shallow.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
__init__(input_shape, len_output_layer=1)
CNN model initialization.
This CNN automatically adapts to the shape of the initial input features.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
array
|
Shape of the input batch (C x H x W). |
required |
len_output_layer
|
int
|
Length of the latent vector. |
1
|
Source code in mlpoppyns/learning/models/model_conv_sbi_shallow.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
convs(x)
Convolution and pooling layers forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the convolution layers. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the convolution and pooling layers. |
Source code in mlpoppyns/learning/models/model_conv_sbi_shallow.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
forward(x)
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the network. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the network after forwarding all layers. |
Source code in mlpoppyns/learning/models/model_conv_sbi_shallow.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
mlpoppyns.learning.models.model_linear
Model for a simple linear neural network.
Authors:
Alberto Garcia Garcia (garciagarcia@ice.csic.es)
ModelLinear
Bases: ModelBase
A linear neural network Model.
Source code in mlpoppyns/learning/models/model_linear.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
__init__(input_shape=None, num_parameters=1)
Linear model initialization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_shape
|
array
|
Shape of the input batch (C x H x W). |
None
|
num_parameters
|
int
|
Number of parameters to predict. |
1
|
Source code in mlpoppyns/learning/models/model_linear.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
forward(x)
Forward pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor for the network. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Output tensor of the network after forwarding all layers. |
Source code in mlpoppyns/learning/models/model_linear.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
mlpoppyns.learning.models.models
Models.
This is just an empty module that gathers all the available modules.
Authors:
Alberto Garcia Garcia (garciagarcia@ice.csic.es)