bitorch_engine.layers.qmha.binary.layer.LearnableBias
- class bitorch_engine.layers.qmha.binary.layer.LearnableBias(out_chn: int)[source]
A module that introduces a learnable bias term to the input tensor.
This module adds a learnable bias parameter to the input tensor along the channel dimension. The bias parameter is learnable and can be optimized during the training process.
- bias
The learnable bias parameter initialized with zeros.
- Type:
nn.Parameter
- Parameters:
out_chn (int) – The number of output channels. This should match the channel dimension of the input tensor to which the bias will be added.
Methods
Initializes the LearnableBias module.
Forward pass of the LearnableBias module.
Attributes
training
- __init__(out_chn: int)[source]
Initializes the LearnableBias module.
- Parameters:
out_chn (int) – The number of output channels for the bias parameter.
- forward(x: Tensor) Tensor [source]
Forward pass of the LearnableBias module.
Adds the learnable bias to the input tensor.
- Parameters:
x (Tensor) – The input tensor to which the learnable bias will be added.
- Returns:
The output tensor after adding the learnable bias to the input.
- Return type:
Tensor