EnhancedLinear Block#
- class EnhancedLinear(layer, activation=None, dropout=None)[source]
Bases:
Module
Enhanced Linear layer class.
This class is a wrapper for enhancing a linear layer with activation and/or dropout.
Initialization of the
EnhancedLinear
class.- Parameters:
layer (torch.nn.Module) – The linear layer to be enhanced.
activation (torch.nn.Module) – The activation function. Default is
None
.dropout (float) – The dropout probability. Default is
None
.
- Example:
>>> linear_layer = torch.nn.Linear(10, 20) >>> activation = torch.nn.ReLU() >>> dropout_prob = 0.5 >>> enhanced_linear = EnhancedLinear( ... linear_layer, ... activation, ... dropout_prob ... )
- forward(x)[source]
Forward pass.
- Parameters:
x (torch.Tensor) – The input tensor.
- Returns:
The output tensor.
- Return type: