normalizers
normalizers
¶
Online feature normalization for continual learning.
Implements online (streaming) normalization that updates estimates of mean and variance at every time step, following the principle of temporal uniformity.
Reference: Welford's online algorithm for numerical stability.
NormalizerState
¶
State for online feature normalization.
Uses Welford's online algorithm for numerically stable estimation of running mean and variance.
Attributes: mean: Running mean estimate per feature var: Running variance estimate per feature sample_count: Number of samples seen decay: Exponential decay factor for estimates (1.0 = no decay, pure online)
OnlineNormalizer(epsilon=1e-08, decay=0.99)
¶
Online feature normalizer for continual learning.
Normalizes features using running estimates of mean and standard deviation:
x_normalized = (x - mean) / (std + epsilon)
The normalizer updates its estimates at every time step, following temporal uniformity. Uses exponential moving average for non-stationary environments.
Attributes: epsilon: Small constant for numerical stability decay: Exponential decay for running estimates (0.99 = slower adaptation)
Args: epsilon: Small constant added to std for numerical stability decay: Exponential decay factor for running estimates. Lower values adapt faster to changes. 1.0 means pure online average (no decay).
Source code in src/alberta_framework/core/normalizers.py
init(feature_dim)
¶
Initialize normalizer state.
Args: feature_dim: Dimension of feature vectors
Returns: Initial normalizer state with zero mean and unit variance
Source code in src/alberta_framework/core/normalizers.py
normalize(state, observation)
¶
Normalize observation and update running statistics.
This method both normalizes the current observation AND updates the running statistics, maintaining temporal uniformity.
Args: state: Current normalizer state observation: Raw feature vector
Returns: Tuple of (normalized_observation, new_state)
Source code in src/alberta_framework/core/normalizers.py
normalize_only(state, observation)
¶
Normalize observation without updating statistics.
Useful for inference or when you want to normalize multiple observations with the same statistics.
Args: state: Current normalizer state observation: Raw feature vector
Returns: Normalized observation
Source code in src/alberta_framework/core/normalizers.py
update_only(state, observation)
¶
Update statistics without returning normalized observation.
Args: state: Current normalizer state observation: Raw feature vector
Returns: Updated normalizer state
Source code in src/alberta_framework/core/normalizers.py
create_normalizer_state(feature_dim, decay=0.99)
¶
Create initial normalizer state.
Convenience function for creating normalizer state without instantiating the OnlineNormalizer class.
Args: feature_dim: Dimension of feature vectors decay: Exponential decay factor
Returns: Initial normalizer state