EQVAEModel<T>
Models & Types · AiDotNet.Diffusion.VAE
Equivariance-preserving VAE (EQ-VAE) with improved latent regularity.
Inheritance: VAEModelBase<T> → EQVAEModel<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
If you rotate or flip an image, the latent representation should rotate or flip in the same way. Standard VAEs don’t guarantee this, leading to inconsistent latent spaces. EQ-VAE adds this guarantee, producing better latents for diffusion models to work with — like having a well-organized workspace.
How It Works
EQ-VAE enforces equivariance constraints on the encoder/decoder pair, ensuring that geometric transformations in pixel space correspond to the same transformations in latent space. This produces smoother, more regular latent distributions that improve downstream diffusion model training and generation quality.
Reference: Xu et al., “EQ-VAE: Equivariance Regularized Latent Space for Improved Generative Image Modeling”, 2025
Example
var vae = new EQVAEModel<float>(inputChannels: 3, latentChannels: 4, baseChannels: 128);
var image = Tensor<float>.CreateRandom(new[] { 1, 3, 512, 512 });
var latent = vae.Encode(image);
Constructors
| Constructor | Summary |
|---|---|
EQVAEModel(int inputChannels, int latentChannels, int baseChannels, double equivarianceWeight, ILossFunction<T> lossFunction, int? seed) |
Initializes a new EQ-VAE model. |
Properties
| Property | Summary |
|---|---|
bool SupportsSlicing { get; } |
|
bool SupportsTiling { get; } |
|
double LatentScaleFactor { get; } |
|
int DownsampleFactor { get; } |
|
int InputChannels { get; } |
|
int LatentChannels { get; } |
Methods
| Method | Summary |
|---|---|
T ComputeEquivarianceLoss(Tensor<T> original, Tensor<T> transformed) |
Computes the equivariance loss between original and transformed encode-decode paths. |
Tensor<T> Decode(Tensor<T> latent) |
|
Tensor<T> Encode(Tensor<T> image, bool sampleMode) |
|
ValueTuple<Tensor<T>, Tensor<T>> EncodeWithDistribution(Tensor<T> image) |