MLPClassifier

class MLPClassifier(**kwargs)[source]

Bases: ClassifierNN

A class used to represent a Multilayer Perceptron (MLP) for classification tasks. This class inherits from the ClassifierNN class.

model_type

A string that represents the type of the model (default is “ffnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • dropout (float) – The dropout probability (default is 0.2).

__init__(self, **kwargs)[source]

Initializes the MLPClassifier object with given or default parameters.

_init_model(self)[source]

Initializes the layers of the neural network based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the neural network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the neural network. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'ffnn'
training: bool

CNNClassifier

class CNNClassifier(**kwargs)[source]

Bases: ClassifierNN

A class used to represent a Convolutional Neural Network (CNN) for classification tasks. This class inherits from the ClassifierNN class.

model_type

A string that represents the type of the model (default is “cnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_filters (int) – The number of filters in the convolutional layer.

  • kernel_size (int) – The size of the kernel in the convolutional layer.

  • pool_size (int) – The size of the pooling layer.

__init__(self, **kwargs)[source]

Initializes the CNNClassifier object with given or default parameters.

_init_model(self)[source]

Initializes the convolutional and fully connected layers of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the CNN.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the CNN. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'cnn'
training: bool

LSTMClassifier

class LSTMClassifier(**kwargs)[source]

Bases: ClassifierNN

A class used to represent a Long Short-Term Memory (LSTM) network for classification tasks. This class inherits from the ClassifierNN class.

model_type

A string that represents the type of the model (default is “rnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_layers (int) – The number of recurrent layers (default is 1).

__init__(self, **kwargs)[source]

Initializes the LSTMClassifier object with given or default parameters.

_init_model(self)[source]

Initializes the LSTM and fully connected layers of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the LSTM network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the LSTM network. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'rnn'
training: bool

GRUClassifier

class GRUClassifier(**kwargs)[source]

Bases: ClassifierNN

A class used to represent a Gated Recurrent Unit (GRU) network for classification tasks. This class inherits from the ClassifierNN class.

model_type

A string that represents the type of the model (default is “rnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_layers (int) – The number of recurrent layers (default is 1).

__init__(self, **kwargs)[source]

Initializes the GRUClassifier object with given or default parameters.

_init_model(self)[source]

Initializes the GRU and fully connected layers of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the GRU network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the GRU network. :param x: The input tensor. :returns: The output tensor, corresponding to the predicted target variable(s).

model_type = 'rnn'
training: bool

BiGRUClassifier

class BiGRUClassifier(**kwargs)[source]

Bases: ClassifierNN

A class used to represent a Bidirectional Gated Recurrent Unit (BiGRU) network for classification tasks. This class inherits from the ClassifierNN class.

model_type

A string that represents the type of the model (default is “rnn”).

Type:

str

Parameters:
  • hidden_size (Union[int, List[int]]) – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_layers (int) – The number of recurrent layers (default is 1).

__init__(self, **kwargs)[source]

Initializes the BiGRUClassifier object with given or default parameters.

_init_model(self)[source]

Initializes the BiGRU layers and fully connected layer of the model based on configuration.

forward(x

torch.Tensor) -> torch.Tensor: Defines the forward pass of the BiGRU network.

forward(x: Tensor) Tensor[source]

Defines the forward pass of the BiGRU network.

Parameters:

x (torch.Tensor) – The input tensor.

Returns:

The output tensor.

Return type:

torch.Tensor

Raises:

RuntimeError – If the model has not been initialized by calling the fit method before calling predict.

model_type = 'rnn'
training: bool

BiLSTMClassifier

class BiLSTMClassifier(**kwargs)[source]

Bases: ClassifierNN

A class used to represent a Bidirectional Long Short-Term Memory (BiLSTM) network for classification tasks. This class inherits from the ClassifierNN class.

Parameters:
  • hidden_size – a list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer

  • num_layers – the number of recurrent layers (default is 1)

model_type

a string that represents the type of the model (default is “rnn”)

Type:

str

__init__(self, \*\*kwargs):

Initializes the BiLSTMClassifier object with given or default parameters.

_init_model(self):

Initializes the BiLSTM layers and fully connected layer of the model based on configuration.

forward(x: torch.Tensor) torch.Tensor:[source]

Defines the forward pass of the BiLSTM network.

forward(x: Tensor) Tensor[source]
model_type = 'rnn'
training: bool

BNNClassifier

class BNNClassifier(**kwargs)[source]

Bases: ClassifierProb

A class used to represent a Bayesian Neural Network (BNN) for classification tasks. This class inherits from the ClassifierProb class.

hidden_size

A list of integers representing the number of nodes in each hidden layer or a single integer representing the number of nodes in a single hidden layer.

Type:

list[int] or int

dropout

The dropout rate for the dropout layers (default is 0.2).

Type:

float

model_type

A string representing the type of the model (default is “ffnn”).

Type:

str

__init__(self, **kwargs)[source]

Initializes the BayesianNNClassifier object with given or default parameters.

_init_model(self)[source]

Initializes the Bayesian Neural Network layers of the model based on configuration.

forward(self, x_data

torch.Tensor, y_data: torch.Tensor=None) -> torch.Tensor: Defines the forward pass of the Bayesian Neural Network.

_initSVI(self) pyro.infer.svi.SVI[source]

Initializes Stochastic Variational Inference (SVI) for Bayesian Inference with an AutoNormal guide.

forward(x_data: Tensor, y_data: Optional[Tensor] = None) Tensor[source]

Defines the forward pass of the Bayesian Neural Network.

Parameters:
Returns:

The output tensor of the model.

Return type:

torch.Tensor

model_type = 'ffnn'
training: bool

BCNNClassifier

class BCNNClassifier(**kwargs)[source]

Bases: ClassifierProb

A class used to represent a Bayesian Convolutional Neural Network (CNN) for probabilistic classification tasks. This class inherits from the ClassifierProb class.

Parameters:
  • hidden_size – A list of integers that represents the number of nodes in each hidden layer or a single integer that represents the number of nodes in a single hidden layer.

  • num_filters – The number of filters in the convolutional layer.

  • kernel_size – The size of the kernel in the convolutional layer.

  • pool_size – The size of the pooling layer.

  • dropout – The dropout rate for regularization.

model_type

A string that represents the type of the model (default is “cnn”).

__init__(self, **kwargs)[source]

Initializes the BayesianCNNClassifier object with given or default parameters.

_init_model(self)[source]

Initializes the Convolutional layers and fully connected layers of the model based on configuration. This model uses PyroModule wrappers for the layers to enable Bayesian inference.

forward(self, x_data

torch.Tensor, y_data: torch.Tensor=None) -> torch.Tensor: Defines the forward pass of the Bayesian CNN, and optionally observes the output if ground truth y_data is provided.

_initSVI(self) pyro.infer.svi.SVI[source]

Initializes Stochastic Variational Inference (SVI) for the model. Defines the guide function to be a Normal distribution that learns to approximate the posterior, and uses Mean Field ELBO as the variational loss.

forward(x_data: Tensor, y_data: Optional[Tensor] = None) Tensor[source]
model_type = 'cnn'
training: bool