autoqild.mi_estimators.neural_networks_torch¶
Neural Nwtowkr implementations for running the PC-softmax and Mine MI estimator.
Classes
|
ClassNet is a fully connected neural network used for classification tasks. |
|
StatNet is a fully connected neural network used for statistical modeling in MINE (Mutual Information Neural Estimation) tasks to estimate mutual information. |
- class autoqild.mi_estimators.neural_networks_torch.ClassNet(in_dim, out_dim, n_units, n_hidden, device, is_pc_softmax=True)[source]¶
Bases:
ModuleClassNet is a fully connected neural network used for classification tasks.
This class implements a simple feedforward neural network with a configurable number of hidden layers and units. It supports a custom softmax function (PC-softmax) for handling imbalanced data.
- Parameters:
in_dim (int) – Number of input features.
out_dim (int) – Number of output classes.
n_units (int) – Number of units in each hidden layer.
n_hidden (int) – Number of hidden layers.
device (torch.device) – Device to run the network on (CPU or GPU).
is_pc_softmax (bool, optional, default=True) – If True, use the custom PC-softmax function in the final layer.
- input¶
Input layer.
- Type:
torch.nn.Linear
Hidden layers.
- Type:
list of torch.nn.Linear
- output¶
Output layer.
- Type:
torch.nn.Linear
- is_pc_softmax¶
Whether to use the PC-softmax function.
- Type:
bool
- device¶
Device used for computation.
- Type:
torch.device
- forward(x_in, label_proportions)[source]¶
Forward pass through the network.
- Parameters:
x_in (torch.Tensor) – Input tensor.
label_proportions (list or torch.Tensor) – Proportions of each class in the dataset.
- Returns:
x_in – Output tensor after applying the network layers.
- Return type:
torch.Tensor
- score(x_in, label_proportions)[source]¶
Compute class probabilities for the input samples.
- Parameters:
x_in (torch.Tensor) – Input tensor.
label_proportions (list or torch.Tensor) – Proportions of each class in the dataset.
- Returns:
x_in – Output tensor with class probabilities.
- Return type:
torch.Tensor
- class autoqild.mi_estimators.neural_networks_torch.StatNet(in_dim, cls_enc=1, n_units=100, n_hidden=1, device='cpu')[source]¶
Bases:
ModuleStatNet is a fully connected neural network used for statistical modeling in MINE (Mutual Information Neural Estimation) tasks to estimate mutual information.
This class implements a simple feedforward neural network with a configurable number of hidden layers and units. It is typically used to model the joint distribution of input features and class labels for MI estimation.
- Parameters:
in_dim (int) – Number of input features.
cls_enc (int, optional, default=1) – Number of classes in the one-hot encoded target variable.
n_units (int, optional, default=100) – Number of units in each hidden layer.
n_hidden (int, optional, default=1) – Number of hidden layers.
device (torch.device, optional, default=`cpu`) – Device to run the network on (CPU or GPU).
- input¶
Input layer.
- Type:
torch.nn.Linear
Hidden layers.
- Type:
list of torch.nn.Linear
- output¶
Output layer.
- Type:
torch.nn.Linear