mdlearn.nn.modules.dense_net
DenseNet module.
Classes
|
- class mdlearn.nn.modules.dense_net.DenseNet(*args: Any, **kwargs: Any)
- __init__(input_dim: int, neurons: List[int] = [128], bias: bool = True, relu_slope: float = 0.0, inplace_activation: bool = False)
DenseNet module for easy feedforward network creation. Creates a neural network with Linear layers and ReLU (or LeakyReLU activation). The returned tensor from the forward function, does not pass through an activation function.
- Parameters
input_dim (int) – Dimension of input tensor (should be flattened).
neurons (List[int], default=[128]) – Linear layers
in_features
.bias (bool, default=True) – Use a bias term in the Linear layers.
relu_slope (float, default=0.0) – If greater than 0.0, will use LeakyReLU activiation with
negative_slope
set torelu_slope
.inplace_activation (bool, default=False) – Sets the inplace option for the activation function.
- Raises
ValueError –
neurons
should specify atleast one layer.
- forward(x: torch.Tensor) torch.Tensor
Forward pass through dense network.
- Parameters
x (torch.Tensor) – Input data.
- Returns
torch.Tensor – The output of the neural network with dimension (batch size, last neuron size).