latent_standardizer
latent_standardizer
¶
Latent-space standardization module for learned denoising priors.
LatentStandardizer
¶
Bases: Module
Optional affine standardization for DiT prior latent targets.
Initialize standardizer buffers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latent_dimension
|
int
|
Size of the latent vector to standardize. |
required |
enabled
|
bool
|
Whether standardization should be applied after fitting. |
True
|
epsilon
|
float
|
Numerical epsilon used for clamping and division. |
1e-06
|
require_fitted
|
bool
|
Whether transform calls should raise before stats exist. |
False
|
Source code in src/versatil/models/decoding/latent/prior/latent_standardizer.py
set_stats
¶
Set precomputed latent mean and standard deviation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mean
|
Tensor
|
Latent mean tensor with shape |
required |
std
|
Tensor
|
Latent standard-deviation tensor with shape |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If shapes are wrong, values are non-finite, or std is invalid. |
Source code in src/versatil/models/decoding/latent/prior/latent_standardizer.py
fit
¶
Fit statistics from latent samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latents
|
Tensor
|
Tensor whose trailing dimension is |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the trailing dimension does not match the latent size. |
Source code in src/versatil/models/decoding/latent/prior/latent_standardizer.py
standardize
¶
Map raw posterior latents to DiT prior training space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latents
|
Tensor
|
Raw latent tensor with trailing latent dimension. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Standardized latents, or the input unchanged when disabled/unfitted. |
Source code in src/versatil/models/decoding/latent/prior/latent_standardizer.py
unstandardize
¶
Map DiT prior samples back to decoder latent space.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
latents
|
Tensor
|
Standardized latent tensor with trailing latent dimension. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Raw-space latents, or the input unchanged when disabled/unfitted. |