Mixed Variable Diffusion Objective
Use this skill when a GSDM recovery needs deterministic diffusion mechanics for mixed continuous and discrete variables: one-hot categorical encoding, arbitrary observation masks, forward noising, decoding, and masked x0 denoising loss.
Do not use this skill as a full neural diffusion implementation. It supplies the objective contract and small numerical helpers used by recovery and tests.
Inputs
- Variable specs with
name,kind, and optionalnum_categories. - Values for each variable.
- Beta schedule and timestep.
- Noise vector.
- Prediction vector and optional loss mask.
Outputs
- Encoded
x0vector. - Noisy
xtvector. - Observation mask expanded to encoded dimensions.
- Masked mean-squared denoising loss.
- Decoded categorical values by argmax.
Workflow
- Encode continuous values as scalar channels.
- Encode categorical values as one-hot channel blocks.
- Expand observed variable names to encoded dimensions.
- Compute
alpha_bar_tfrom the beta schedule. - Produce
xt = sqrt(alpha_bar_t) * x0 + sqrt(1 - alpha_bar_t) * noise. - Compute masked MSE over latent dimensions.
CLI
python scripts/diffusion_objective.py --demo --output /tmp/gsdm_objective.json
Validation
python -m pytest tests
The tests cover categorical round-trips, the noising equation, and masked loss behavior.
Limitations
The helpers use Python lists and floats for portability. They are intended for small recovery checks, not high-throughput training.