duo_ai.utils.model¶
Functions¶
|
Apply orthogonal initialization to a module's weights and zero to biases. |
|
Apply Xavier uniform initialization to a module's weights and zero to biases. |
Module Contents¶
- duo_ai.utils.model.orthogonal_init(module, gain=nn.init.calculate_gain('relu'))[source]¶
Apply orthogonal initialization to a module’s weights and zero to biases.
- Parameters:
module (nn.Module) – The module to initialize (e.g., nn.Linear, nn.Conv2d).
gain (float, optional) – Scaling factor for the orthogonal initialization. Default is relu gain.
- Returns:
The initialized module.
- Return type:
nn.Module
Examples
>>> layer = nn.Linear(10, 5) >>> orthogonal_init(layer)
- duo_ai.utils.model.xavier_uniform_init(module, gain=1.0)[source]¶
Apply Xavier uniform initialization to a module’s weights and zero to biases.
- Parameters:
module (nn.Module) – The module to initialize (e.g., nn.Linear, nn.Conv2d).
gain (float, optional) – Scaling factor for the Xavier initialization. Default is 1.0.
- Returns:
The initialized module.
- Return type:
nn.Module
Examples
>>> layer = nn.Linear(10, 5) >>> xavier_uniform_init(layer)