ada_norm
ada_norm
¶
AdaNorm
¶
AdaNorm(base_norm, conditioning_dimension, feature_dim, use_gate=False, activation=value, init_strategy='zero')
Bases: Module
Adaptive normalization layer with conditional affine modulation.
Initialize adaptive normalization.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_norm
|
Module
|
Normalization module applied before modulation. |
required |
conditioning_dimension
|
int
|
Dimension of the conditioning vector. |
required |
feature_dim
|
int
|
Feature dimension to modulate. |
required |
use_gate
|
bool
|
Whether to return a learned residual gate. |
False
|
activation
|
str
|
Activation used inside the modulation projection. |
value
|
init_strategy
|
Literal['zero', 'xavier']
|
Initialization strategy for modulation weights. |
'zero'
|
Source code in src/versatil/models/layers/normalization/ada_norm.py
forward
¶
Forward pass with conditioning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
Input tensor to normalize and modulate. |
required |
condition
|
Tensor
|
Conditioning tensor of shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tuple of (normalized+modulated x, gate). Gate is a learned |
Tensor
|
tensor when use_gate=True, or 1.0 when use_gate=False. |