Glow¤
Module: generative_models.models.flow.glow
Source: generative_models/models/flow/glow.py
Overview¤
Glow is the retained single-scale image normalizing flow baseline.
The current runtime applies a stack of Glow blocks at the fixed channel width
from image_shape[-1]. It does not implement the squeeze/split multi-scale
stages from the original Glow paper.
Public Surface¤
GlowConfig¤
Typed configuration for the retained Glow runtime.
Retained fields include:
coupling_network: theCouplingNetworkConfigused by each affine coupling layerimage_shape: the image tensor shape consumed by the flowblocks_per_scale: the number of sequential Glow blocks in the retained single-scale stack- shared
FlowConfigfields such asinput_dim,latent_dim, and the base distribution settings
Glow¤
Single-scale image flow baseline.
Retained behavior:
forward(images, *, rngs)andinverse(latents, *, rngs)transform tensors with the configuredimage_shape__call__(images, *, rngs)returns the shared flow output dictionary withz,logdet, andlog_probgenerate(n_samples, *, rngs)samples Gaussian latents withimage_shapeand maps them through the inverse flowsample(...)remains the shared alias forgenerate(...)
GlowBlock, ActNormLayer, InvertibleConv1x1, AffineCouplingLayer¤
These helper layers remain implementation details of the retained Glow block stack. Channel mismatches fail explicitly instead of silently no-oping.
Example¤
from flax import nnx
from artifex.generative_models.core.configuration import (
CouplingNetworkConfig,
GlowConfig,
)
from artifex.generative_models.models.flow import Glow
coupling_network = CouplingNetworkConfig(
name="glow_coupling",
hidden_dims=(512, 512),
activation="relu",
network_type="mlp",
)
config = GlowConfig(
name="glow",
coupling_network=coupling_network,
input_dim=32 * 32 * 3,
image_shape=(32, 32, 3),
blocks_per_scale=6,
)
model = Glow(config, rngs=nnx.Rngs(0))
samples = model.generate(n_samples=4, rngs=nnx.Rngs(1))