ANN
Simple Dense Model
- class bias_amplification.attacker_models.ANN.simpleDenseModel(input_dims, output_dims, num_layers=5, numFirst=16, activations=['relu', 'relu', 'sigmoid', 'relu', 'relu'])[source]
Bases:
ModuleThis class defines a simple dense neural network model, used mainly for the attacker models in the bias amplification analysis.
Methods
This function counts the number of parameters in the neural network.
This function filters the activations to be used in the neural network.
forward(x)This function performs the forward pass through the neural network.
This function initialises the layers of the neural network.
- __init__(input_dims, output_dims, num_layers=5, numFirst=16, activations=['relu', 'relu', 'sigmoid', 'relu', 'relu'])[source]
This function initialises the neural network.
- Parameters:
- input_dims: int
The number of input dimensions.
- output_dims: int
The number of output dimensions.
- num_layers: int
The number of layers in the neural network.
- numFirst: int
The number of neurons in the first layer.
- activations: list
The activations to use in the layers.
- count_params()[source]
This function counts the number of parameters in the neural network.
- Returns:
- int
The number of parameters in the neural network.
- filterActivations()[source]
This function filters the activations to be used in the neural network. If the number of activations is less than the number of layers, the activations are extended with the identity activation.
- Parameters:
- activations: list
The activations to use in the layers.
- Returns:
- None
- forward(x)[source]
This function performs the forward pass through the neural network.
- Parameters:
- x: torch.Tensor
The input to the neural network.
- Returns:
- x: torch.Tensor
The output of the neural network.
- initLayers()[source]
This function initialises the layers of the neural network.
- Parameters:
- input_dims: int
The number of input dimensions.
- output_dims: int
The number of output dimensions.
- num_layers: int
The number of layers in the neural network.
- numFirst: int
The number of neurons in the first layer.
- activations: list
The activations to use in the layers.
- Returns:
- None
- Raises:
- ValueError: If the number of layers is less than 1.
- training: bool