Latent diffusion and Diffusion Transformers
Diffuse in an autoencoder's compact code instead of raw data, and the cost drops while the autoencoder sets a quality ceiling. Swap the denoiser for a transformer and feed it the step and condition through adaptive normalization.
What runs in CodeSplash
- DNN061Latent diffusion model (LDM) Partly runs in CodeSplash (Experimental)
- DNN062Diffusion Transformer (DiT) Explained here
- Synthetic data — tabular diffusion (TabDDPM-style) Experimental
- Autoencoder (neural map and reconstruction anomalies) Verified in Python and R
You will be able to
- Describe the two stages of latent diffusion and what each one limits
- Say what the autoencoder's rebuild quality means for the final samples
- Explain how a Diffusion Transformer takes the step and condition through adaLN
- Say what CodeSplash runs and what it explains
Two stages
ReadLatent diffusionLatent diffusionRuns diffusion on an autoencoder's compact codes instead of raw data, then decodes; cheaper, but bounded by the autoencoder. splits generation in two:
- Train an autoencoder that compresses each item into a much smaller code, often regularized like a VAE or a VQ-VAE.
- Freeze it, and train a diffusion model on the codes. To sample, run diffusion in code space and decode once at the end.
Every diffusion step now works on the small code instead of the full item, which is what made high-resolution text-to-image models affordable.
Noise in the code, decode at the end
ReadIn the reference's example a four-value row is encoded to a two-value code, 0.94 and 0.59. Diffusion noises the code, not the row: it becomes 0.896 and 0.439. Decoding maps it back to four values.
The two noisy code values decode to four, so the decoder decides what the other two look like. Whatever the autoencoder can't represent, the samples can't contain.
The ceiling is the autoencoder
PredictPredict first
A latent diffusion model's samples miss fine detail. Its autoencoder rebuilds training items blurrily. What limits the samples?
Reveal
The autoencoder. Diffusion can only produce codes; the decoder turns them into items. If rebuilds of real items are blurry, decoded samples are too. Check the autoencoder's held-out rebuilds before blaming the diffusion stage.
Check the first stage first
ExploreThe first stage is an autoencoder like those earlier in the track, and it deserves the same checks: held-out rebuild error and how well its code keeps neighbors.
An autoencoder compressed 150 rows into 2 coordinates; 8 rows with reconstruction errors ≥ 0.141 are flagged as anomalies.
- Mean reconstruction error
- 0.0395
- Trustworthiness (k = 10)
- 0.9779
- Anomalies
- 8
- Threshold
- 0.1414
Plots
View data
| species | Coordinate 1 | Coordinate 2 |
|---|---|---|
| setosa | 0.8994 | 0.5535 |
| setosa | 0.9614 | 0.1290 |
| setosa | 1.041 | 0.3232 |
| setosa | 1.050 | 0.2386 |
| setosa | 0.9346 | 0.6399 |
| setosa | 0.6920 | 0.8300 |
| setosa | 1.031 | 0.4823 |
| setosa | 0.9246 | 0.4699 |
| setosa | 1.111 | 0.0860 |
| setosa | 0.9879 | 0.2291 |
| setosa | 0.7797 | 0.7039 |
| setosa | 0.9827 | 0.4750 |
| setosa | 1.028 | 0.1515 |
| setosa | 1.208 | 0.2006 |
| setosa | 0.6507 | 0.9397 |
| setosa | 0.5948 | 1.188 |
| setosa | 0.7307 | 0.8459 |
| setosa | 0.8656 | 0.5412 |
| setosa | 0.6110 | 0.7550 |
| setosa | 0.8558 | 0.7800 |
| setosa | 0.7610 | 0.4417 |
| setosa | 0.8218 | 0.6900 |
| setosa | 1.102 | 0.6698 |
| setosa | 0.7623 | 0.3291 |
| setosa | 0.9534 | 0.4590 |
| setosa | 0.9081 | 0.1166 |
| setosa | 0.8447 | 0.4406 |
| setosa | 0.8541 | 0.5451 |
| setosa | 0.8632 | 0.4625 |
| setosa | 1.011 | 0.3136 |
| setosa | 0.9764 | 0.2207 |
| setosa | 0.7121 | 0.4197 |
| setosa | 0.8799 | 1.009 |
| setosa | 0.7451 | 1.082 |
| setosa | 0.9538 | 0.2157 |
| setosa | 0.9510 | 0.3041 |
| setosa | 0.7609 | 0.5356 |
| setosa | 1.002 | 0.6513 |
| setosa | 1.126 | 0.1742 |
| setosa | 0.8896 | 0.4647 |
| setosa | 0.9103 | 0.5495 |
| setosa | 1.024 | −0.4486 |
| setosa | 1.132 | 0.3436 |
| setosa | 0.7735 | 0.4957 |
| setosa | 0.7826 | 0.7464 |
| setosa | 0.9591 | 0.1226 |
| setosa | 0.8804 | 0.7830 |
| setosa | 1.062 | 0.3270 |
| setosa | 0.8172 | 0.7070 |
| setosa | 0.9332 | 0.3872 |
| versicolor | −0.5769 | −0.0873 |
| versicolor | −0.3555 | −0.0717 |
| versicolor | −0.5746 | −0.1889 |
| versicolor | 0.1318 | −0.7268 |
| versicolor | −0.3387 | −0.4084 |
| versicolor | −0.0251 | −0.3516 |
| versicolor | −0.3847 | −0.0073 |
| versicolor | 0.4388 | −0.5574 |
| versicolor | −0.3375 | −0.3061 |
| versicolor | 0.1561 | −0.4038 |
First 60 of 150 rows.
View data
| Anomaly | Reconstruction error |
|---|---|
| false | 0.0038 |
| false | 0.0104 |
| false | 0.0023 |
| false | 0.0084 |
| false | 0.0011 |
| false | 0.0008 |
| false | 0.0356 |
| false | 0.0021 |
| false | 0.0171 |
| false | 0.0120 |
| false | 0.0198 |
| false | 0.0095 |
| false | 0.0075 |
| false | 0.0252 |
| false | 0.0704 |
| false | 0.0247 |
| false | 0.0087 |
| false | 0.0031 |
| false | 0.0458 |
| false | 0.0058 |
| false | 0.0481 |
| false | 0.0086 |
| false | 0.0391 |
| false | 0.0086 |
| false | 0.0269 |
| false | 0.0186 |
| false | 0.0055 |
| false | 0.0109 |
| false | 0.0189 |
| false | 0.0081 |
| false | 0.0023 |
| false | 0.0369 |
| false | 0.0286 |
| false | 0.0141 |
| false | 0.0046 |
| false | 0.0149 |
| false | 0.0715 |
| false | 0.0061 |
| false | 0.0213 |
| false | 0.0072 |
| false | 0.0037 |
| false | 0.0231 |
| false | 0.0375 |
| false | 0.0341 |
| false | 0.0227 |
| false | 0.0039 |
| false | 0.0076 |
| false | 0.0108 |
| false | 0.0090 |
| false | 0.0046 |
| true | 0.1810 |
| false | 0.0220 |
| false | 0.1093 |
| false | 0.0026 |
| false | 0.0536 |
| false | 0.0116 |
| false | 0.0037 |
| false | 0.0193 |
| false | 0.1183 |
| false | 0.0575 |
First 60 of 150 rows.
View data
| Epoch | Reconstruction loss | Set |
|---|---|---|
| 1 | 0.9193 | train |
| 2 | 0.8359 | train |
| 3 | 0.7698 | train |
| 4 | 0.7086 | train |
| 5 | 0.6472 | train |
| 6 | 0.5876 | train |
| 7 | 0.5328 | train |
| 8 | 0.4868 | train |
| 9 | 0.4519 | train |
| 10 | 0.4259 | train |
| 11 | 0.4032 | train |
| 12 | 0.3784 | train |
| 13 | 0.3499 | train |
| 14 | 0.3198 | train |
| 15 | 0.2915 | train |
| 16 | 0.2671 | train |
| 17 | 0.2466 | train |
| 18 | 0.2291 | train |
| 19 | 0.2146 | train |
| 20 | 0.2032 | train |
| 21 | 0.1949 | train |
| 22 | 0.1884 | train |
| 23 | 0.1821 | train |
| 24 | 0.1752 | train |
| 25 | 0.1676 | train |
| 26 | 0.1593 | train |
| 27 | 0.1502 | train |
| 28 | 0.1402 | train |
| 29 | 0.1297 | train |
| 30 | 0.1196 | train |
| 31 | 0.1108 | train |
| 32 | 0.1036 | train |
| 33 | 0.0981 | train |
| 34 | 0.0943 | train |
| 35 | 0.0919 | train |
| 36 | 0.0907 | train |
| 37 | 0.0900 | train |
| 38 | 0.0890 | train |
| 39 | 0.0872 | train |
| 40 | 0.0848 | train |
| 41 | 0.0821 | train |
| 42 | 0.0798 | train |
| 43 | 0.0780 | train |
| 44 | 0.0766 | train |
| 45 | 0.0754 | train |
| 46 | 0.0743 | train |
| 47 | 0.0734 | train |
| 48 | 0.0725 | train |
| 49 | 0.0713 | train |
| 50 | 0.0699 | train |
| 51 | 0.0683 | train |
| 52 | 0.0669 | train |
| 53 | 0.0656 | train |
| 54 | 0.0644 | train |
| 55 | 0.0632 | train |
| 56 | 0.0624 | train |
| 57 | 0.0619 | train |
| 58 | 0.0616 | train |
| 59 | 0.0613 | train |
| 60 | 0.0609 | train |
First 60 of 200 rows.
Rows reconstructed worst
| Rank | Row | Reconstruction error | sepal_length | sepal_width | petal_length | petal_width |
|---|---|---|---|---|---|---|
| 1 | 115 | 0.2760 | 5.800 | 2.800 | 5.100 | 2.400 |
| 2 | 107 | 0.2472 | 4.900 | 2.500 | 4.500 | 1.700 |
| 3 | 101 | 0.2335 | 6.300 | 3.300 | 6 | 2.500 |
| 4 | 51 | 0.1810 | 7 | 3.200 | 4.700 | 1.400 |
| 5 | 137 | 0.1731 | 6.300 | 3.400 | 5.600 | 2.400 |
| 6 | 149 | 0.1554 | 6.200 | 3.400 | 5.400 | 2.300 |
| 7 | 122 | 0.1531 | 5.600 | 2.800 | 4.900 | 2 |
| 8 | 77 | 0.1414 | 6.800 | 2.800 | 4.800 | 1.400 |
| 9 | 63 | 0.1393 | 6 | 2.200 | 4 | 1 |
| 10 | 130 | 0.1242 | 7.200 | 3 | 5.800 | 1.600 |
| 11 | 59 | 0.1183 | 6.600 | 2.900 | 4.600 | 1.300 |
| 12 | 66 | 0.1139 | 6.700 | 3.100 | 4.400 | 1.400 |
| 13 | 145 | 0.1111 | 6.700 | 3.300 | 5.700 | 2.500 |
| 14 | 53 | 0.1093 | 6.900 | 3.100 | 4.900 | 1.500 |
| 15 | 88 | 0.1092 | 6.300 | 2.300 | 4.400 | 1.300 |
| 16 | 114 | 0.0994 | 5.700 | 2.500 | 5 | 2 |
| 17 | 116 | 0.0945 | 6.400 | 3.200 | 5.300 | 2.300 |
| 18 | 76 | 0.0935 | 6.600 | 3 | 4.400 | 1.400 |
| 19 | 132 | 0.0892 | 7.900 | 3.800 | 6.400 | 2 |
| 20 | 85 | 0.0855 | 5.400 | 3 | 4.500 | 1.500 |
The exact R script · R R version 4.5.1 (2025-06-13)
# Autoencoder (neural map and reconstruction anomalies)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method discover.autoencoder 1.1.0 · spec b20a603fe1151222
# Dataset: ml_iris (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # cs_deep_*: torch networks with shared initial weights (twin of codesplash.deep)
# %% Data — standardized numbers (median-imputed), one-hot categories
IMPUTE <- "median"
SCALE <- "standard"
# Training options, live progress and checkpoints (twin: codesplash.deep.trainer.configure).
cs_deep_trainer_configure(list(
optimizer = "default",
lr_schedule = "none",
warmup_epochs = 0,
grad_clip = 0,
ema_decay = 0,
swa_start = 0,
history_every_step = FALSE,
profile = "parity",
checkpoint_every = NULL
), out_dir = "target/academy-parity/run-8142/discover.autoencoder/iris_map/out-r")
FEATURES <- c("sepal_length", "sepal_width", "petal_length", "petal_width")
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ml_iris.parquet", col_select = FEATURES))
warnings <- list()
design <- cs_ml_design(
df, FEATURES,
kinds = list(
sepal_length = "numeric",
sepal_width = "numeric",
petal_length = "numeric",
petal_width = "numeric"
),
levels = list(
),
impute = IMPUTE,
scale = SCALE
)
fitted <- cs_ml_design_fit(design, df)
X <- unname(cs_ml_design_apply(fitted, df)) # numbers imputed / scaled; categories one-hot (missing -> all zero)
rows <- seq_len(nrow(df)) - 1L
LABEL <- "species"
if (!is.null(LABEL)) df[[LABEL]] <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ml_iris.parquet", col_select = LABEL))[[LABEL]]
# %% Autoencoder (torch for R, float64, one thread): encoder -> linear bottleneck -> mirrored decoder
HIDDEN <- as.integer(unlist(c(8)))
LATENT <- as.integer(2)
fit <- cs_deep_fit_autoencoder(
X, HIDDEN, LATENT,
activation = "tanh",
epochs = as.integer(200),
lr = 0.02,
batch_size = NULL,
weight_decay = 0,
noise = 0,
seed = 42
)
Z <- fit$embedding # n x LATENT bottleneck coordinates
errors <- fit$error # mean squared reconstruction error per row (standardized features)
# %% Anomalies by reconstruction error
RULE <- "share"
flagged <- cs_ml_flag(errors, RULE, 0.05, 1)
flags <- flagged$flag
threshold <- flagged$threshold
ord <- order(-errors, rows) # largest error first, ties by row
# %% Neighborhood preservation of the map (same rows in both engines)
sample <- cs_ml_sample_rows(length(rows))
k_eval <- min(10L, length(sample) - 2L)
trust <- cs_ml_trustworthiness(X[sample, , drop = FALSE], Z[sample, , drop = FALSE], k_eval)
# %% Artifacts
out <- cs_ml_out_dir("target/academy-parity/run-8142/discover.autoencoder/iris_map/out-r")
emb <- data.frame(row = as.integer(rows))
for (j in seq_len(LATENT)) emb[[paste0("dim_", j)]] <- Z[, j]
nanoparquet::write_parquet(emb, file.path(out, "embedding.parquet"))
nanoparquet::write_parquet(data.frame(row = as.integer(rows), score = errors, anomaly = flags), file.path(out, "labels.parquet"))
nanoparquet::write_parquet(cs_deep_history_frame(fit$history), file.path(out, "history.parquet"))
# %% Result
history <- cs_deep_history_frame(fit$history)
values <- list(
n = length(rows), n_features = ncol(X), latent_dim = LATENT, recon_mse = mean(errors),
error_check = cs_ml_checksum(errors, rows), n_flagged = sum(flags), threshold = threshold,
final_loss = history$loss[nrow(history)], epochs_run = fit$epochs_run, trustworthiness = trust
)
for (j in seq_len(LATENT)) values[[sprintf("emb_check[%d]", j)]] <- cs_ml_checksum(Z[, j], rows)
for (rank in seq_len(min(10L, length(ord)))) {
values[[sprintf("top_row[%d]", rank)]] <- rows[ord[rank]]
values[[sprintf("top_error[%d]", rank)]] <- errors[ord[rank]]
}
top <- utils::head(ord, 20L)
table_rows <- lapply(seq_along(top), function(rank) {
i <- top[rank]
r <- list(rank = rank, row = rows[i] + 1L, error = errors[i])
for (f in FEATURES) {
v <- df[[f]][rows[i] + 1L]
r[[f]] <- if (is.na(v)) NULL else if (is.numeric(v)) v else as.character(v)
}
r
})
pick <- cs_ml_sample_rows(length(rows), 5000)
groups <- if (is.null(LABEL)) rep("All rows", length(pick)) else {
g <- df[[LABEL]][rows[pick] + 1L]
ifelse(is.na(g), "(missing)", as.character(g))
}
charts <- list()
if (LATENT >= 2L) {
charts[[length(charts) + 1L]] <- cs_chart("map", "cluster-scatter", "Autoencoder map (bottleneck coordinates 1 and 2)", list(
x = cs_col("Coordinate 1", Z[pick, 1], "numeric"),
y = cs_col("Coordinate 2", Z[pick, 2], "numeric"),
cluster = cs_col(if (is.null(LABEL)) "Group" else LABEL, groups, "categorical")
), note = if (length(pick) == length(rows)) NULL else sprintf("%s of %s rows shown.", format(length(pick), big.mark = ","), format(length(rows), big.mark = ",")))
}
charts[[length(charts) + 1L]] <- cs_chart("errors", "anomaly-scores", "Reconstruction error distribution", list(
score = cs_col("Reconstruction error", errors, "numeric"),
anomaly = cs_col("Anomaly", flags, "boolean")
), controls = list(threshold = threshold))
charts[[length(charts) + 1L]] <- cs_chart("training", "learning-curve", "Training loss by epoch", list(
n = cs_col("Epoch", history$epoch, "numeric"),
score = cs_col("Reconstruction loss", history$loss, "numeric"),
set = cs_col("Set", rep("train", nrow(history)), "categorical")
))
cs_publish(list(
title = "Autoencoder (neural map and reconstruction anomalies)",
engine = cs_engine_info("torch", "nanoparquet"),
n = length(rows),
summary = sprintf("An autoencoder compressed %d rows into %d coordinate%s; %d rows with reconstruction errors ≥ %s are flagged as anomalies.",
length(rows), LATENT, if (LATENT != 1L) "s" else "", sum(flags), format(signif(threshold, 3))),
statistics = list(
list(key = "recon_mse", label = "Mean reconstruction error", value = mean(errors)),
list(key = "trustworthiness", label = sprintf("Trustworthiness (k = %d)", k_eval), value = trust),
list(key = "n_flagged", label = "Anomalies", value = sum(flags), format = "integer"),
list(key = "threshold", label = "Threshold", value = threshold)
),
tables = list(list(
key = "top", title = "Rows reconstructed worst",
columns = c(list(list(key = "rank", label = "Rank", type = "integer"), list(key = "row", label = "Row", type = "integer"),
list(key = "error", label = "Reconstruction error", type = "number")),
lapply(FEATURES, function(f) list(key = f, label = f))),
rows = table_rows
)),
charts = charts,
values = values,
warnings = warnings,
artifacts = list(
list(key = "embedding", path = file.path(out, "embedding.parquet"), format = "parquet"),
list(key = "labels", path = file.path(out, "labels.parquet"), format = "parquet"),
list(key = "history", path = file.path(out, "history.parquet"), format = "parquet")
)
))
An autoencoder compressed 150 rows into 2 coordinates; 8 rows with reconstruction errors ≥ 0.141 are flagged as anomalies.
- Mean reconstruction error
- 0.0395
- Trustworthiness (k = 10)
- 0.9779
- Anomalies
- 8
- Threshold
- 0.1414
To keep this page light, the plots are shown once, under the R tab.
Rows reconstructed worst
| Rank | Row | Reconstruction error | sepal_length | sepal_width | petal_length | petal_width |
|---|---|---|---|---|---|---|
| 1 | 115 | 0.2760 | 5.800 | 2.800 | 5.100 | 2.400 |
| 2 | 107 | 0.2472 | 4.900 | 2.500 | 4.500 | 1.700 |
| 3 | 101 | 0.2335 | 6.300 | 3.300 | 6 | 2.500 |
| 4 | 51 | 0.1810 | 7 | 3.200 | 4.700 | 1.400 |
| 5 | 137 | 0.1731 | 6.300 | 3.400 | 5.600 | 2.400 |
| 6 | 149 | 0.1554 | 6.200 | 3.400 | 5.400 | 2.300 |
| 7 | 122 | 0.1531 | 5.600 | 2.800 | 4.900 | 2 |
| 8 | 77 | 0.1414 | 6.800 | 2.800 | 4.800 | 1.400 |
| 9 | 63 | 0.1393 | 6 | 2.200 | 4 | 1 |
| 10 | 130 | 0.1242 | 7.200 | 3 | 5.800 | 1.600 |
| 11 | 59 | 0.1183 | 6.600 | 2.900 | 4.600 | 1.300 |
| 12 | 66 | 0.1139 | 6.700 | 3.100 | 4.400 | 1.400 |
| 13 | 145 | 0.1111 | 6.700 | 3.300 | 5.700 | 2.500 |
| 14 | 53 | 0.1093 | 6.900 | 3.100 | 4.900 | 1.500 |
| 15 | 88 | 0.1092 | 6.300 | 2.300 | 4.400 | 1.300 |
| 16 | 114 | 0.0994 | 5.700 | 2.500 | 5 | 2 |
| 17 | 116 | 0.0945 | 6.400 | 3.200 | 5.300 | 2.300 |
| 18 | 76 | 0.0935 | 6.600 | 3 | 4.400 | 1.400 |
| 19 | 132 | 0.0892 | 7.900 | 3.800 | 6.400 | 2 |
| 20 | 85 | 0.0855 | 5.400 | 3 | 4.500 | 1.500 |
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Autoencoder (neural map and reconstruction anomalies)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method discover.autoencoder 1.1.0 · spec b20a603fe1151222
# Dataset: ml_iris (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash import ml as csml
from codesplash.deep import core as deep # twin of codesplashr::cs_deep_* (shared initial weights, Adam written out)
from codesplash.ml import anomaly as csanom
from codesplash.ml import embed as csembed
# %% Data — standardized numbers (median-imputed), one-hot categories
IMPUTE = "median"
SCALE = "standard"
from codesplash.deep import trainer as deep_trainer # training options, live progress, checkpoints (twin: cs_deep_trainer_*)
deep_trainer.configure(
{
"optimizer": "default",
"lr_schedule": "none",
"warmup_epochs": 0,
"grad_clip": 0,
"ema_decay": 0,
"swa_start": 0,
"history_every_step": False,
"profile": "parity",
"checkpoint_every": None,
},
out_dir="target/academy-parity/run-8142/discover.autoencoder/iris_map/out-python",
)
FEATURES = ["sepal_length", "sepal_width", "petal_length", "petal_width"]
df = pd.read_parquet("tests/parity/fixtures/ml_iris.parquet", columns=FEATURES)
warnings = []
design = csml.Design.for_frame(
df,
FEATURES,
kinds={
"sepal_length": "numeric",
"sepal_width": "numeric",
"petal_length": "numeric",
"petal_width": "numeric",
},
levels={
},
impute=IMPUTE,
scale=SCALE,
)
fitted = design.fit(df)
X = fitted.transform(df) # numbers imputed / scaled; categories one-hot (missing → all zero)
rows = np.arange(len(df))
LABEL = "species"
if LABEL:
df[LABEL] = pd.read_parquet("tests/parity/fixtures/ml_iris.parquet", columns=[LABEL])[LABEL]
# %% Autoencoder (PyTorch, float64, one thread): encoder → linear bottleneck → mirrored decoder
HIDDEN = [int(u) for u in [8]]
LATENT = 2
fit = deep.fit_autoencoder(
X, HIDDEN, LATENT,
activation="tanh",
epochs=200,
lr=0.02,
batch_size=None,
weight_decay=0,
noise=0,
seed=42,
)
Z = fit["embedding"] # n × LATENT bottleneck coordinates
errors = fit["error"] # mean squared reconstruction error per row (standardized features)
# %% Anomalies by reconstruction error
RULE = "share"
flags, threshold = csanom.flag(errors, RULE, 0.05, 1)
order = np.lexsort((rows, -errors)) # largest error first, ties by row
# %% Neighborhood preservation of the map (same rows in both engines)
sample = csembed.sample_rows(len(rows))
k_eval = min(10, len(sample) - 2)
trust = csembed.trustworthiness(X[sample], Z[sample], k_eval)
# %% Artifacts
out = csml.out_dir("target/academy-parity/run-8142/discover.autoencoder/iris_map/out-python")
emb = pd.DataFrame({"row": rows.astype(np.int64), **{f"dim_{j + 1}": Z[:, j] for j in range(LATENT)}})
emb.to_parquet(os.path.join(out, "embedding.parquet"), index=False)
pd.DataFrame({"row": rows.astype(np.int64), "score": errors, "anomaly": flags}).to_parquet(os.path.join(out, "labels.parquet"), index=False)
deep.history_frame(fit["history"]).to_parquet(os.path.join(out, "history.parquet"), index=False)
# %% Result
values = {
"n": len(rows),
"n_features": int(X.shape[1]),
"latent_dim": LATENT,
"recon_mse": float(np.mean(errors)),
"error_check": csembed.checksum(errors, rows),
"n_flagged": int(flags.sum()),
"threshold": float(threshold),
"final_loss": float(fit["history"][-1]["loss"]),
"epochs_run": int(fit["epochs_run"]),
"trustworthiness": trust,
}
for j in range(LATENT):
values[f"emb_check[{j + 1}]"] = csembed.checksum(Z[:, j], rows)
for rank, i in enumerate(order[:10], start=1):
values[f"top_row[{rank}]"] = int(rows[i])
values[f"top_error[{rank}]"] = float(errors[i])
top = order[:20]
table_rows = []
for rank, i in enumerate(top, start=1):
r = {"rank": rank, "row": int(rows[i]) + 1, "error": float(errors[i])}
for f in FEATURES:
v = df[f].iloc[rows[i]]
r[f] = None if pd.isna(v) else (v if isinstance(v, (int, float)) else str(v)) # None, NaN, pd.NA, NaT
table_rows.append(r)
pick = csembed.sample_rows(len(rows), 5000)
groups = [("All rows" if LABEL is None else ("(missing)" if pd.isna(v) else str(v))) for v in (df[LABEL].iloc[rows[pick]] if LABEL else [None] * len(pick))]
charts = []
if LATENT >= 2:
charts.append(cs.chart("map", "cluster-scatter", "Autoencoder map (bottleneck coordinates 1 and 2)", {
"x": cs.col("Coordinate 1", Z[pick, 0], "numeric"),
"y": cs.col("Coordinate 2", Z[pick, 1], "numeric"),
"cluster": cs.col(LABEL or "Group", groups, "categorical"),
}, note=None if len(pick) == len(rows) else f"{len(pick):,} of {len(rows):,} rows shown."))
charts.append(cs.chart("errors", "anomaly-scores", "Reconstruction error distribution", {
"score": cs.col("Reconstruction error", errors, "numeric"),
"anomaly": cs.col("Anomaly", [bool(x) for x in flags], "boolean"),
}, controls={"threshold": float(threshold)}))
charts.append(cs.chart("training", "learning-curve", "Training loss by epoch", {
"n": cs.col("Epoch", [h["epoch"] for h in fit["history"]], "numeric"),
"score": cs.col("Reconstruction loss", [h["loss"] for h in fit["history"]], "numeric"),
"set": cs.col("Set", ["train"] * len(fit["history"]), "categorical"),
}))
cs.publish({
"title": "Autoencoder (neural map and reconstruction anomalies)",
"engine": cs.engine_info("torch", "numpy", "pandas"),
"n": len(rows),
"summary": f"An autoencoder compressed {len(rows)} rows into {LATENT} coordinate{'s' if LATENT != 1 else ''}; {int(flags.sum())} rows with reconstruction errors ≥ {threshold:.3g} are flagged as anomalies.",
"statistics": [
{"key": "recon_mse", "label": "Mean reconstruction error", "value": float(np.mean(errors))},
{"key": "trustworthiness", "label": f"Trustworthiness (k = {k_eval})", "value": trust},
{"key": "n_flagged", "label": "Anomalies", "value": int(flags.sum()), "format": "integer"},
{"key": "threshold", "label": "Threshold", "value": float(threshold)},
],
"tables": [{
"key": "top",
"title": "Rows reconstructed worst",
"columns": [{"key": "rank", "label": "Rank", "type": "integer"}, {"key": "row", "label": "Row", "type": "integer"},
{"key": "error", "label": "Reconstruction error", "type": "number"}] + [{"key": f, "label": f} for f in FEATURES],
"rows": table_rows,
}],
"charts": charts,
"values": values,
"warnings": warnings,
"artifacts": [
{"key": "embedding", "path": os.path.join(out, "embedding.parquet"), "format": "parquet"},
{"key": "labels", "path": os.path.join(out, "labels.parquet"), "format": "parquet"},
{"key": "history", "path": os.path.join(out, "history.parquet"), "format": "parquet"},
],
})
Here a two-coordinate code rebuilds iris with a mean squared error of 0.040 and a trustworthiness of 0.978. For latent diffusion you'd also want codes on a scale the diffusion schedule expects, which is one reason VAE-style regularization is used.
Reference · DNN061 · Partly runs in CodeSplashLatent diffusion model (LDM)Latent diffusion trains the denoising process in a compressed autoencoder representation instead of raw pixels. This reduces generative computation and enables flexible conditioning, with reconstruction quality…A transformer as the denoiser
ReadImage diffusion models long used a U-Net as the denoiser. A Diffusion TransformerDiffusion TransformerA transformer used as a diffusion denoiser, with the step and condition entering through learned scale and shift of normalization. (DiT) cuts the noisy latent into patches, treats them as tokens, and runs a transformer.
The step and the condition, such as a class, enter through adaptive layer normalization (adaLN): a small network maps them to a scale and shift for each normalized layer, . In the adaLN-Zero version, each block's residual branch also gets a gate that starts at zero, so every block begins as the identity.
In the reference's example two tokens are normalized and modulated; the first token's values become −1.164, 0.133 and 1.488.
Reference · DNN062 · Explained hereDiffusion Transformer (DiT)DiT replaces a conventional convolutional diffusion denoiser with a transformer operating on latent patches. Time and other conditioning modulate transformer blocks, making architecture scaling a central design axis.What runs here
Read320 synthetic rows over 8 columns from 320 training rows with a diffusion model. Numeric columns differ from the data by a mean Kolmogorov–Smirnov distance of 0.136 and categories by a mean total variation of 0.025.
- Synthetic rows
- 320
- Mean KS distance
- 0.1361
- Mean TV distance
- 0.0250
- Rows copied from the data
- 0
Plots
View data
| Density | Source | age |
|---|---|---|
| 0.0230 | real | 18.950 |
| 0.0016 | real | 20.850 |
| 0.0049 | real | 22.750 |
| 0.0148 | real | 24.650 |
| 0.0148 | real | 26.550 |
| 0.0181 | real | 28.450 |
| 0.0197 | real | 30.350 |
| 0.0296 | real | 32.250 |
| 0.0362 | real | 34.150 |
| 0.0115 | real | 36.050 |
| 0.0362 | real | 37.950 |
| 0.0313 | real | 39.850 |
| 0.0296 | real | 41.750 |
| 0.0280 | real | 43.650 |
| 0.0280 | real | 45.550 |
| 0.0181 | real | 47.450 |
| 0.0164 | real | 49.350 |
| 0.0197 | real | 51.250 |
| 0.0362 | real | 53.150 |
| 0.0148 | real | 55.050 |
| 0.0164 | real | 56.950 |
| 0.0181 | real | 58.850 |
| 0.0082 | real | 60.750 |
| 0.0164 | real | 62.650 |
| 0.0049 | real | 64.550 |
| 0.0115 | real | 66.450 |
| 0.0066 | real | 68.350 |
| 0.0049 | real | 70.250 |
| 0.0016 | real | 72.150 |
| 0.0049 | real | 74.050 |
| 0.0411 | synthetic | 18.950 |
| 0.0049 | synthetic | 20.850 |
| 0.0066 | synthetic | 22.750 |
| 0.0197 | synthetic | 24.650 |
| 0.0132 | synthetic | 26.550 |
| 0.0164 | synthetic | 28.450 |
| 0.0263 | synthetic | 30.350 |
| 0.0362 | synthetic | 32.250 |
| 0.0477 | synthetic | 34.150 |
| 0.0115 | synthetic | 36.050 |
| 0.0411 | synthetic | 37.950 |
| 0.0411 | synthetic | 39.850 |
| 0.0280 | synthetic | 41.750 |
| 0.0296 | synthetic | 43.650 |
| 0.0280 | synthetic | 45.550 |
| 0.0181 | synthetic | 47.450 |
| 0.0214 | synthetic | 49.350 |
| 0.0132 | synthetic | 51.250 |
| 0.0280 | synthetic | 53.150 |
| 0.0082 | synthetic | 55.050 |
| 0.0099 | synthetic | 56.950 |
| 0.0033 | synthetic | 58.850 |
| 0.0066 | synthetic | 60.750 |
| 0.0132 | synthetic | 62.650 |
| 0.0016 | synthetic | 64.550 |
| 0.0049 | synthetic | 66.450 |
| 0.0033 | synthetic | 68.350 |
| 0.0033 | synthetic | 70.250 |
| 0 | synthetic | 72.150 |
| 0 | synthetic | 74.050 |
View data
| Density | Source | annual income |
|---|---|---|
| 3.010e-6 | real | 6851.93 |
| 1.605e-5 | real | 10141.74 |
| 2.107e-5 | real | 13431.55 |
| 2.408e-5 | real | 16721.36 |
| 3.511e-5 | real | 20011.17 |
| 4.113e-5 | real | 23300.98 |
| 2.809e-5 | real | 26590.79 |
| 2.408e-5 | real | 29880.60 |
| 2.508e-5 | real | 33170.41 |
| 1.605e-5 | real | 36460.22 |
| 1.605e-5 | real | 39750.03 |
| 1.505e-5 | real | 43039.84 |
| 1.003e-5 | real | 46329.65 |
| 5.016e-6 | real | 49619.46 |
| 6.019e-6 | real | 52909.27 |
| 4.013e-6 | real | 56199.07 |
| 4.013e-6 | real | 59488.88 |
| 4.013e-6 | real | 62778.69 |
| 1.003e-6 | real | 66068.50 |
| 1.003e-6 | real | 69358.31 |
| 1.003e-6 | real | 72648.12 |
| 0 | real | 75937.93 |
| 1.003e-6 | real | 79227.74 |
| 1.003e-6 | real | 82517.55 |
| 0 | real | 85807.36 |
| 0 | real | 89097.17 |
| 0 | real | 92386.98 |
| 0 | real | 95676.79 |
| 0 | real | 98966.60 |
| 1.003e-6 | real | 102256.41 |
| 5.016e-6 | synthetic | 6851.93 |
| 1.906e-5 | synthetic | 10141.74 |
| 2.608e-5 | synthetic | 13431.55 |
| 3.210e-5 | synthetic | 16721.36 |
| 3.912e-5 | synthetic | 20011.17 |
| 4.615e-5 | synthetic | 23300.98 |
| 2.608e-5 | synthetic | 26590.79 |
| 2.107e-5 | synthetic | 29880.60 |
| 2.709e-5 | synthetic | 33170.41 |
| 1.003e-5 | synthetic | 36460.22 |
| 1.505e-5 | synthetic | 39750.03 |
| 1.104e-5 | synthetic | 43039.84 |
| 9.029e-6 | synthetic | 46329.65 |
| 2.006e-6 | synthetic | 49619.46 |
| 3.010e-6 | synthetic | 52909.27 |
| 3.010e-6 | synthetic | 56199.07 |
| 3.010e-6 | synthetic | 59488.88 |
| 4.013e-6 | synthetic | 62778.69 |
| 0 | synthetic | 66068.50 |
| 1.003e-6 | synthetic | 69358.31 |
| 1.003e-6 | synthetic | 72648.12 |
| 0 | synthetic | 75937.93 |
| 0 | synthetic | 79227.74 |
| 0 | synthetic | 82517.55 |
| 0 | synthetic | 85807.36 |
| 0 | synthetic | 89097.17 |
| 0 | synthetic | 92386.98 |
| 0 | synthetic | 95676.79 |
| 0 | synthetic | 98966.60 |
| 0 | synthetic | 102256.41 |
View data
| Density | Source | tenure_months |
|---|---|---|
| 0.0938 | real | 0.7667 |
| 0.0224 | real | 2.300 |
| 0.0183 | real | 3.833 |
| 0.0306 | real | 5.367 |
| 0.0204 | real | 6.900 |
| 0.0265 | real | 8.433 |
| 0.0204 | real | 9.967 |
| 0.0530 | real | 11.500 |
| 0.0183 | real | 13.033 |
| 0.0510 | real | 14.567 |
| 0.0183 | real | 16.100 |
| 0.0367 | real | 17.633 |
| 0.0224 | real | 19.167 |
| 0.0448 | real | 20.700 |
| 0.0469 | real | 22.233 |
| 0.0082 | real | 23.767 |
| 0.0306 | real | 25.300 |
| 0.0061 | real | 26.833 |
| 0.0183 | real | 28.367 |
| 0.0041 | real | 29.900 |
| 0.0143 | real | 31.433 |
| 0.0061 | real | 32.967 |
| 0.0183 | real | 34.500 |
| 0.0020 | real | 36.033 |
| 0.0041 | real | 37.567 |
| 0 | real | 39.100 |
| 0.0061 | real | 40.633 |
| 0.0041 | real | 42.167 |
| 0.0020 | real | 43.700 |
| 0.0041 | real | 45.233 |
| 0.1916 | synthetic | 0.7667 |
| 0.0285 | synthetic | 2.300 |
| 0.0285 | synthetic | 3.833 |
| 0.0611 | synthetic | 5.367 |
| 0.0163 | synthetic | 6.900 |
| 0.0326 | synthetic | 8.433 |
| 0.0265 | synthetic | 9.967 |
| 0.0408 | synthetic | 11.500 |
| 0.0122 | synthetic | 13.033 |
| 0.0571 | synthetic | 14.567 |
| 0.0102 | synthetic | 16.100 |
| 0.0204 | synthetic | 17.633 |
| 0.0265 | synthetic | 19.167 |
| 0.0183 | synthetic | 20.700 |
| 0.0122 | synthetic | 22.233 |
| 0.0082 | synthetic | 23.767 |
| 0.0143 | synthetic | 25.300 |
| 0.0102 | synthetic | 26.833 |
| 0.0102 | synthetic | 28.367 |
| 0.0041 | synthetic | 29.900 |
| 0.0061 | synthetic | 31.433 |
| 0.0020 | synthetic | 32.967 |
| 0.0082 | synthetic | 34.500 |
| 0 | synthetic | 36.033 |
| 0.0020 | synthetic | 37.567 |
| 0 | synthetic | 39.100 |
| 0.0020 | synthetic | 40.633 |
| 0.0020 | synthetic | 42.167 |
| 0 | synthetic | 43.700 |
| 0 | synthetic | 45.233 |
View data
| Density | Source | signup |
|---|---|---|
| 0.0005 | real | 17582.23 |
| 0.0007 | real | 17654.70 |
| 0.0005 | real | 17727.17 |
| 0.0005 | real | 17799.63 |
| 0.0004 | real | 17872.10 |
| 0.0005 | real | 17944.57 |
| 0.0006 | real | 18017.03 |
| 0.0004 | real | 18089.50 |
| 0.0005 | real | 18161.97 |
| 0.0005 | real | 18234.43 |
| 0.0001 | real | 18306.90 |
| 0.0009 | real | 18379.37 |
| 0.0006 | real | 18451.83 |
| 0.0003 | real | 18524.30 |
| 0.0005 | real | 18596.77 |
| 0.0004 | real | 18669.23 |
| 0.0002 | real | 18741.70 |
| 0.0005 | real | 18814.17 |
| 0.0006 | real | 18886.63 |
| 0.0005 | real | 18959.10 |
| 0.0005 | real | 19031.57 |
| 0.0005 | real | 19104.03 |
| 0.0003 | real | 19176.50 |
| 0.0006 | real | 19248.97 |
| 0.0004 | real | 19321.43 |
| 0.0003 | real | 19393.90 |
| 0.0002 | real | 19466.37 |
| 0.0005 | real | 19538.83 |
| 0.0003 | real | 19611.30 |
| 0.0004 | real | 19683.77 |
| 8.625e-5 | synthetic | 17582.23 |
| 0.0004 | synthetic | 17654.70 |
| 0.0006 | synthetic | 17727.17 |
| 0.0004 | synthetic | 17799.63 |
| 0.0002 | synthetic | 17872.10 |
| 0.0005 | synthetic | 17944.57 |
| 0.0004 | synthetic | 18017.03 |
| 0.0002 | synthetic | 18089.50 |
| 0.0004 | synthetic | 18161.97 |
| 0.0006 | synthetic | 18234.43 |
| 8.625e-5 | synthetic | 18306.90 |
| 0.0007 | synthetic | 18379.37 |
| 0.0005 | synthetic | 18451.83 |
| 0.0004 | synthetic | 18524.30 |
| 0.0007 | synthetic | 18596.77 |
| 0.0005 | synthetic | 18669.23 |
| 0.0002 | synthetic | 18741.70 |
| 0.0004 | synthetic | 18814.17 |
| 0.0005 | synthetic | 18886.63 |
| 0.0005 | synthetic | 18959.10 |
| 0.0005 | synthetic | 19031.57 |
| 0.0007 | synthetic | 19104.03 |
| 0.0006 | synthetic | 19176.50 |
| 0.0010 | synthetic | 19248.97 |
| 0.0006 | synthetic | 19321.43 |
| 0.0003 | synthetic | 19393.90 |
| 0.0001 | synthetic | 19466.37 |
| 0.0004 | synthetic | 19538.83 |
| 0.0004 | synthetic | 19611.30 |
| 0.0007 | synthetic | 19683.77 |
View data
| plan | Share | Source |
|---|---|---|
| basic | 0.3563 | real |
| plus | 0.3969 | real |
| premium | 0.2469 | real |
| basic | 0.3656 | synthetic |
| plus | 0.4281 | synthetic |
| premium | 0.2062 | synthetic |
View data
| region | Share | Source |
|---|---|---|
| east | 0.2848 | real |
| north | 0.2718 | real |
| south | 0.3042 | real |
| west | 0.1392 | real |
| east | 0.3003 | synthetic |
| north | 0.2684 | synthetic |
| south | 0.3035 | synthetic |
| west | 0.1278 | synthetic |
View data
| churned | Share | Source |
|---|---|---|
| false | 0.7688 | real |
| true | 0.2313 | real |
| false | 0.7500 | synthetic |
| true | 0.2500 | synthetic |
View data
| Column | Column | Difference |
|---|---|---|
| age | age | 0 |
| annual income | age | 0.0421 |
| tenure_months | age | 0.0710 |
| signup | age | −0.1504 |
| visits | age | −0.0133 |
| age | annual income | 0.0421 |
| annual income | annual income | 0 |
| tenure_months | annual income | −0.0589 |
| signup | annual income | −0.0369 |
| visits | annual income | 0.0470 |
| age | tenure_months | 0.0710 |
| annual income | tenure_months | −0.0589 |
| tenure_months | tenure_months | 0 |
| signup | tenure_months | −0.1931 |
| visits | tenure_months | 0.0302 |
| age | signup | −0.1504 |
| annual income | signup | −0.0369 |
| tenure_months | signup | −0.1931 |
| signup | signup | 0 |
| visits | signup | 0.0255 |
| age | visits | −0.0133 |
| annual income | visits | 0.0470 |
| tenure_months | visits | 0.0302 |
| signup | visits | 0.0255 |
| visits | visits | 0 |
View data
| Part | Loss | Epoch |
|---|---|---|
| total | 1.386 | 1 |
| total | 1.096 | 2 |
| total | 0.9667 | 3 |
| total | 0.8794 | 4 |
| total | 0.8250 | 5 |
| total | 0.7882 | 6 |
| total | 0.7781 | 7 |
| total | 0.7751 | 8 |
| total | 0.6782 | 9 |
| total | 0.6740 | 10 |
| total | 0.6872 | 11 |
| total | 0.6637 | 12 |
| total | 0.5879 | 13 |
| total | 0.6128 | 14 |
| total | 0.6745 | 15 |
| total | 0.6132 | 16 |
| total | 0.6427 | 17 |
| total | 0.5494 | 18 |
| total | 0.6406 | 19 |
| total | 0.6113 | 20 |
| total | 0.6053 | 21 |
| total | 0.5755 | 22 |
| total | 0.5861 | 23 |
| total | 0.6201 | 24 |
| total | 0.5877 | 25 |
| total | 0.5747 | 26 |
| total | 0.5686 | 27 |
| total | 0.5493 | 28 |
| total | 0.5486 | 29 |
| total | 0.6531 | 30 |
| total | 0.5363 | 31 |
| total | 0.4971 | 32 |
| total | 0.5068 | 33 |
| total | 0.5410 | 34 |
| total | 0.5903 | 35 |
| total | 0.4745 | 36 |
| total | 0.4939 | 37 |
| total | 0.5151 | 38 |
| total | 0.5760 | 39 |
| total | 0.5046 | 40 |
| total | 0.4950 | 41 |
| total | 0.5005 | 42 |
| total | 0.5061 | 43 |
| total | 0.5493 | 44 |
| total | 0.5263 | 45 |
| total | 0.5481 | 46 |
| total | 0.5355 | 47 |
| total | 0.5018 | 48 |
| total | 0.5249 | 49 |
| total | 0.5197 | 50 |
| total | 0.5612 | 51 |
| total | 0.4989 | 52 |
| total | 0.5442 | 53 |
| total | 0.5393 | 54 |
| total | 0.5502 | 55 |
| total | 0.5185 | 56 |
| total | 0.5256 | 57 |
| total | 0.4957 | 58 |
| total | 0.5281 | 59 |
| total | 0.4604 | 60 |
First 60 of 300 rows.
Small t is almost clean data (a fine-detail task); large t is almost pure noise.
View data
| Part | Diffusion step t | Loss |
|---|---|---|
| Gaussian (numbers) | 2 | 1.091 |
| Gaussian (numbers) | 5 | 1.007 |
| Gaussian (numbers) | 8 | 0.9521 |
| Gaussian (numbers) | 10 | 0.8506 |
| Gaussian (numbers) | 12 | 0.8196 |
| Gaussian (numbers) | 15 | 0.7090 |
| Gaussian (numbers) | 18 | 0.6306 |
| Gaussian (numbers) | 20 | 0.5891 |
| Gaussian (numbers) | 22 | 0.5913 |
| Gaussian (numbers) | 25 | 0.4474 |
| Gaussian (numbers) | 28 | 0.3712 |
| Gaussian (numbers) | 30 | 0.3342 |
| Gaussian (numbers) | 32 | 0.2898 |
| Gaussian (numbers) | 35 | 0.2229 |
| Gaussian (numbers) | 38 | 0.1493 |
| Gaussian (numbers) | 40 | 0.1219 |
| Gaussian (numbers) | 42 | 0.0991 |
| Gaussian (numbers) | 45 | 0.0652 |
| Gaussian (numbers) | 48 | 0.0622 |
| Gaussian (numbers) | 50 | 0.0569 |
| multinomial (categories) | 2 | 0.0161 |
| multinomial (categories) | 5 | 0.0265 |
| multinomial (categories) | 8 | 0.0272 |
| multinomial (categories) | 10 | 0.0332 |
| multinomial (categories) | 12 | 0.0323 |
| multinomial (categories) | 15 | 0.0365 |
| multinomial (categories) | 18 | 0.0344 |
| multinomial (categories) | 20 | 0.0326 |
| multinomial (categories) | 22 | 0.0289 |
| multinomial (categories) | 25 | 0.0253 |
| multinomial (categories) | 28 | 0.0208 |
| multinomial (categories) | 30 | 0.0179 |
| multinomial (categories) | 32 | 0.0146 |
| multinomial (categories) | 35 | 0.0095 |
| multinomial (categories) | 38 | 0.0061 |
| multinomial (categories) | 40 | 0.0037 |
| multinomial (categories) | 42 | 0.0021 |
| multinomial (categories) | 45 | 0.0006 |
| multinomial (categories) | 48 | 6.345e-5 |
| multinomial (categories) | 50 | 9.501e-7 |
Assumptions
- Enough rows for a neural generator — 293 complete training rows — neural generators have many weights to learn and can memorize small tables; compare with the copula or sequential trees.
- Training stayed finite — The loss over the last 10% of epochs averaged 0.493.
- No synthetic row copies a training row — 0 synthetic rows are identical to a training row; the scorecard's distance to closest record checks near-copies.
- Synthetic columns match the data — Distance from the training rows: numeric columns 0.136 (mean Kolmogorov–Smirnov distance); categories 0.025 (mean total variation) — above 0.10, so some columns' distributions differ visibly from the data; the scorecard shows which columns and pairs.
Real vs synthetic, column by column
| Column | Kind | Real | Synthetic | Distance | Measure |
|---|---|---|---|---|---|
| age | numeric | 43.14 ± 13.1 | 39.21 ± 12 | 0.1313 | Kolmogorov–Smirnov D |
| annual income | numeric | 2.929e+04 ± 1.43e+04 | 2.644e+04 ± 1.24e+04 | 0.0990 | Kolmogorov–Smirnov D |
| tenure_months | numeric | 15 ± 10.7 | 9.8 ± 9.53 | 0.2344 | Kolmogorov–Smirnov D |
| plan | categorical | plus 39.7% | plus 42.8% | 0.0406 | total variation |
| region | categorical | south 30.4% | south 30.4% | 0.0155 | total variation |
| churned | boolean | false 76.9% | false 75.0% | 0.0187 | total variation |
| signup | temporal | 2020-11-05 ± 621 days | 2021-03-30 ± 601 days | 0.1156 | Kolmogorov–Smirnov D |
| visits | numeric | 3.394 ± 2.09 | 3.013 ± 1.78 | 0.1000 | Kolmogorov–Smirnov D |
- 80 of 400 rows (20%) were held out of training so privacy and utility can be checked against rows the generator never saw.
The exact R script · R R version 4.5.1 (2025-06-13)
# Synthetic data — tabular diffusion (TabDDPM-style)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method synth.diffusion 1.0.2 · spec 9e3bbe3915d08f98
# Dataset: g1_customers (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr)
# %% Data
COLUMNS <- c("age", "annual income", "tenure_months", "plan", "region", "churned", "signup", "visits")
KINDS <- list(
age = "numeric",
`annual income` = "numeric",
tenure_months = "numeric",
plan = "categorical",
region = "categorical",
churned = "boolean",
signup = "temporal",
visits = "numeric"
)
LEVELS <- list(
plan = c("basic", "plus", "premium"),
region = c("east", "north", "south", "west")
)
SEED <- 42
loaded <- cs_synth_load("tests/parity/fixtures/g1_customers.parquet", COLUMNS, KINDS, LEVELS)
cols <- loaded$cols; n_input <- loaded$n
for (c in cols) if (c$kind == "numeric") cs_check_finite(c$values, c$name) # infinite values stop the run (registry/errors.yaml)
rng <- cs_rng(SEED) # shared stream: the same holdout and the same synthetic rows in Python and R
sp <- cs_synth_split(n_input, 0.2, rng)
train_rows <- sp$train; holdout_rows <- sp$holdout
train <- lapply(cols, cs_synth_take, rows = train_rows)
N_OUT <- length(train_rows)
warnings <- list()
fit_values <- list()
extra_tables <- list()
extra_charts <- list()
assumptions <- list()
model_note <- ""
if (length(holdout_rows)) {
warnings <- c(warnings, sprintf("%s of %s rows (%.0f%%) were held out of training so privacy and utility can be checked against rows the generator never saw.",
format(length(holdout_rows), big.mark = ","), format(n_input, big.mark = ","), 100 * length(holdout_rows) / n_input))
}
for (c in train) if (mean(cs_synth_missing(c)) == 1) cs_error("CS_E_ALL_MISSING", column = c$name) # no values in the training rows
n_complete <- length(cs_synth_complete(train))
assumptions[[1]] <- list(
key = "enough_rows", label = "Enough rows for a neural generator",
status = if (n_complete >= 1000) "pass" else "warn",
detail = paste0(sprintf("%s complete training rows", format(n_complete, big.mark = ",")),
if (n_complete >= 1000) "." else " — neural generators have many weights to learn and can memorize small tables; compare with the copula or sequential trees.")
)
# %% Generate
# Gaussian diffusion of normal scores + multinomial diffusion of categories over 50 steps (cosine schedule);
# one MLP predicts the noise and the categories' x0 from [x_t, one-hot x_t, time embedding].
# Twin of codesplash.synth.neural.fit_diffusion (TabDDPM-style, written from the papers).
HIDDEN <- as.integer(unlist(c(64, 64)))
fit <- cs_synth_diffusion(
train, N_OUT, HIDDEN,
steps = as.integer(50),
epochs = as.integer(100),
batch_size = 128,
lr = 0.002,
time_dim = as.integer(16),
seed = SEED
)
synth <- fit$cols
hist <- fit$history
history <- data.frame(
epoch = vapply(hist, function(h) as.numeric(h$epoch), numeric(1)),
loss = vapply(hist, function(h) h$loss, numeric(1)),
loss_num = vapply(hist, function(h) h$loss_num, numeric(1)),
loss_cat = vapply(hist, function(h) h$loss_cat, numeric(1))
)
HAS_NUM <- any(vapply(train, function(c) !c$coded, logical(1)))
HAS_CAT <- any(vapply(train, function(c) c$coded, logical(1)))
last <- max(1L, nrow(history) %/% 10L) # the last 10% of epochs
tail_rows <- (nrow(history) - last + 1L):nrow(history)
fit_values$steps <- fit$facts$steps
fit_values$batch_size <- fit$facts$batch_size
fit_values$final_loss <- mean(history$loss[tail_rows])
if (HAS_NUM) fit_values$loss_num <- mean(history$loss_num[tail_rows])
if (HAS_CAT) fit_values$loss_cat <- mean(history$loss_cat[tail_rows])
model_note <- " with a diffusion model"
parts <- c(total = "loss")
if (HAS_NUM) parts <- c(parts, `Gaussian (numbers)` = "loss_num")
if (HAS_CAT) parts <- c(parts, `multinomial (categories)` = "loss_cat")
ne <- nrow(history)
extra_charts[[length(extra_charts) + 1L]] <- cs_chart("training", "training-components", "Denoising loss by epoch", list(
x = cs_col("Epoch", rep(history$epoch, length(parts)), "numeric"),
value = cs_col("Loss", unlist(lapply(parts, function(k) history[[k]]), use.names = FALSE), "numeric"),
component = cs_col("Part", rep(names(parts), each = ne), "categorical", levels = names(parts))
))
by_t <- fit$by_t
t_parts <- c()
if (HAS_NUM) t_parts <- c(t_parts, `Gaussian (numbers)` = 2L)
if (HAS_CAT) t_parts <- c(t_parts, `multinomial (categories)` = 3L)
extra_charts[[length(extra_charts) + 1L]] <- cs_chart("timesteps", "timestep-loss", "Denoising loss by diffusion step", list(
t = cs_col("Diffusion step t", rep(by_t[, 1], length(t_parts)), "numeric"),
value = cs_col("Loss", unlist(lapply(t_parts, function(j) by_t[, j]), use.names = FALSE), "numeric"),
component = cs_col("Part", rep(names(t_parts), each = nrow(by_t)), "categorical", levels = names(t_parts))
), note = "Small t is almost clean data (a fine-detail task); large t is almost pure noise.")
for (r in seq_len(nrow(by_t))) {
if (HAS_NUM) fit_values[[sprintf("loss_t_num[%d]", as.integer(by_t[r, 1]))]] <- by_t[r, 2]
if (HAS_CAT) fit_values[[sprintf("loss_t_cat[%d]", as.integer(by_t[r, 1]))]] <- by_t[r, 3]
}
finite <- all(is.finite(history$loss))
assumptions[[length(assumptions) + 1L]] <- list(
key = "training_stable", label = "Training stayed finite",
status = if (finite) "pass" else "fail",
detail = if (finite) sprintf("The loss over the last 10%% of epochs averaged %s.", format(signif(fit_values$final_loss, 3))) else
"A loss became infinite or undefined; lower the learning rate."
)
synth <- cs_synth_add_missing(synth, train, rng, "keep_rate") # each column's missing share, at random
# %% Write and compare
out <- cs_ml_out_dir("target/academy-parity/run-8142/synth.diffusion/customers_all/out-r")
path <- cs_synth_write(file.path(out, "synthetic.parquet"), synth)
split <- cs_synth_write_split(file.path(out, "split.parquet"), n_input, train_rows, holdout_rows)
nanoparquet::write_parquet(history, file.path(out, "history.parquet"))
sm <- cs_synth_summarize(train, synth, length(train_rows), n_input, length(holdout_rows), fit_values)
values <- sm$values
assumptions[[length(assumptions) + 1L]] <- list(
key = "no_copies", label = "No synthetic row copies a training row",
status = if (values$exact_matches == 0) "pass" else "warn",
detail = sprintf("%s synthetic row%s identical to a training row; the scorecard's distance to closest record checks near-copies.",
format(values$exact_matches, big.mark = ","), if (values$exact_matches != 1) "s are" else " is")
)
# Fidelity (Stage 12.10): judged on the mean column distances, the scorecard's column fidelity (good at >= 0.9 = 1 - 0.1).
fid_d <- numeric(); fid_t <- character()
if (!is.nan(values$fidelity_ks_mean)) {
fid_d <- c(fid_d, values$fidelity_ks_mean)
fid_t <- c(fid_t, sprintf("numeric columns %.3f (mean Kolmogorov–Smirnov distance)", values$fidelity_ks_mean))
}
if (!is.nan(values$fidelity_tv_mean)) {
fid_d <- c(fid_d, values$fidelity_tv_mean)
fid_t <- c(fid_t, sprintf("categories %.3f (mean total variation)", values$fidelity_tv_mean))
}
assumptions[[length(assumptions) + 1L]] <- if (!length(fid_d)) {
list(key = "fidelity", label = "Synthetic columns match the data", status = "info",
detail = "No column could be compared with the data.")
} else {
list(key = "fidelity", label = "Synthetic columns match the data",
status = if (max(fid_d) <= 0.1) "pass" else "warn",
detail = paste0("Distance from the training rows: ", paste(fid_t, collapse = "; "),
if (max(fid_d) <= 0.1) " — at most 0.10, which the Synthetic studio's scorecard rates as good column fidelity."
else " — above 0.10, so some columns' distributions differ visibly from the data; the scorecard shows which columns and pairs."))
}
summary <- sprintf("%s synthetic rows over %d column%s from %s training rows%s.",
format(values$n_rows, big.mark = ","), length(COLUMNS), if (length(COLUMNS) != 1) "s" else "",
format(length(train_rows), big.mark = ","), model_note)
if (!is.nan(values$fidelity_ks_mean)) {
summary <- paste0(summary, sprintf(" Numeric columns differ from the data by a mean Kolmogorov–Smirnov distance of %.3f", values$fidelity_ks_mean),
if (!is.nan(values$fidelity_tv_mean)) sprintf(" and categories by a mean total variation of %.3f.", values$fidelity_tv_mean) else ".")
} else if (!is.nan(values$fidelity_tv_mean)) {
summary <- paste0(summary, sprintf(" Categories differ from the data by a mean total variation of %.3f.", values$fidelity_tv_mean))
}
if (values$exact_matches > 0) {
summary <- paste0(summary, sprintf(" %s synthetic row%s identical to a training row.", format(values$exact_matches, big.mark = ","),
if (values$exact_matches != 1) "s are" else " is"))
}
cs_publish(list(
title = "Synthetic data — tabular diffusion (TabDDPM-style)",
engine = cs_engine_info("torch", "nanoparquet", "nanoparquet"),
n = values$n_real, summary = summary,
statistics = list(
list(key = "n_rows", label = "Synthetic rows", value = values$n_rows, format = "integer"),
list(key = "fidelity_ks_mean", label = "Mean KS distance", value = values$fidelity_ks_mean),
list(key = "fidelity_tv_mean", label = "Mean TV distance", value = values$fidelity_tv_mean),
list(key = "exact_matches", label = "Rows copied from the data", value = values$exact_matches, format = "integer")),
tables = c(list(sm$table), extra_tables),
values = values, charts = c(sm$charts, extra_charts), assumptions = assumptions, warnings = warnings,
artifacts = list(list(key = "synthetic", path = path, format = "parquet", title = "Synthetic rows"),
list(key = "split", path = split, format = "parquet", title = "Training and holdout rows"),
list(key = "history", path = file.path(out, "history.parquet"), format = "parquet", title = "Training history")),
model = list(kind = "generator", columns = I(COLUMNS), params = list(
n_rows = NULL,
steps = 50,
hidden_layers = c(64, 64),
epochs = 100,
batch_size = 128,
learning_rate = 0.002,
time_dim = 16,
missing = "keep_rate",
holdout = 0.2
))
))
320 synthetic rows over 8 columns from 320 training rows with a diffusion model. Numeric columns differ from the data by a mean Kolmogorov–Smirnov distance of 0.136 and categories by a mean total variation of 0.025.
- Synthetic rows
- 320
- Mean KS distance
- 0.1361
- Mean TV distance
- 0.0250
- Rows copied from the data
- 0
To keep this page light, the plots are shown once, under the R tab.
Assumptions
- Enough rows for a neural generator — 293 complete training rows — neural generators have many weights to learn and can memorize small tables; compare with the copula or sequential trees.
- Training stayed finite — The loss over the last 10% of epochs averaged 0.493.
- No synthetic row copies a training row — 0 synthetic rows are identical to a training row; the scorecard's distance to closest record checks near-copies.
- Synthetic columns match the data — Distance from the training rows: numeric columns 0.136 (mean Kolmogorov–Smirnov distance); categories 0.025 (mean total variation) — above 0.10, so some columns' distributions differ visibly from the data; the scorecard shows which columns and pairs.
Real vs synthetic, column by column
| Column | Kind | Real | Synthetic | Distance | Measure |
|---|---|---|---|---|---|
| age | numeric | 43.14 ± 13.1 | 39.21 ± 12 | 0.1312 | Kolmogorov–Smirnov D |
| annual income | numeric | 2.929e+04 ± 1.43e+04 | 2.644e+04 ± 1.24e+04 | 0.0990 | Kolmogorov–Smirnov D |
| tenure_months | numeric | 15 ± 10.7 | 9.8 ± 9.53 | 0.2344 | Kolmogorov–Smirnov D |
| plan | categorical | plus 39.7% | plus 42.8% | 0.0406 | total variation |
| region | categorical | south 30.4% | south 30.4% | 0.0155 | total variation |
| churned | boolean | false 76.9% | false 75.0% | 0.0188 | total variation |
| signup | temporal | 2020-11-05 ± 621 days | 2021-03-30 ± 601 days | 0.1156 | Kolmogorov–Smirnov D |
| visits | numeric | 3.394 ± 2.09 | 3.013 ± 1.78 | 0.1000 | Kolmogorov–Smirnov D |
- 80 of 400 rows (20%) were held out of training so privacy and utility can be checked against rows the generator never saw.
The exact Python script · Python Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Synthetic data — tabular diffusion (TabDDPM-style)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method synth.diffusion 1.0.2 · spec 9e3bbe3915d08f98
# Dataset: g1_customers (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
import os
import numpy as np
import pandas as pd
import codesplash as cs
from codesplash.errors import check_finite
from codesplash.ml.run import out_dir
from codesplash.stats.rng import Rng
from codesplash.synth import common as sy
from codesplash.synth import neural # twin of codesplashr::cs_synth_diffusion (TabDDPM-style, written from the papers)
# %% Data
COLUMNS = ["age", "annual income", "tenure_months", "plan", "region", "churned", "signup", "visits"]
KINDS = {
"age": "numeric",
"annual income": "numeric",
"tenure_months": "numeric",
"plan": "categorical",
"region": "categorical",
"churned": "boolean",
"signup": "temporal",
"visits": "numeric",
}
LEVELS = {
"plan": ["basic", "plus", "premium"],
"region": ["east", "north", "south", "west"],
}
SEED = 42
cols, n_input = sy.load("tests/parity/fixtures/g1_customers.parquet", COLUMNS, KINDS, LEVELS)
for c in cols:
if c.kind == "numeric":
check_finite(c.values, c.name) # infinite values stop the run (registry/errors.yaml)
rng = Rng(SEED) # shared stream: the same holdout and the same synthetic rows in Python and R
train_rows, holdout_rows = sy.split_holdout(n_input, 0.2, rng)
train = [c.take(train_rows) for c in cols]
N_OUT = None or len(train_rows)
warnings = []
fit_values = {}
extra_tables = []
extra_charts = []
assumptions = []
model_note = ""
if len(holdout_rows):
warnings.append(f"{len(holdout_rows):,} of {n_input:,} rows ({len(holdout_rows) / n_input:.0%}) were held out of training so privacy and utility can be checked against rows the generator never saw.")
for c in train:
share = float(np.mean(c.missing()))
if share == 1.0:
cs.cs_error("CS_E_ALL_MISSING", column=c.name) # no values in the training rows
n_complete = len(sy.complete_rows(train))
assumptions.append({
"key": "enough_rows",
"label": "Enough rows for a neural generator",
"status": "pass" if n_complete >= 1000 else "warn",
"detail": f"{n_complete:,} complete training rows"
+ ("." if n_complete >= 1000 else " — neural generators have many weights to learn and can memorize small tables; compare with the copula or sequential trees."),
})
# %% Generate
# Gaussian diffusion of normal scores + multinomial diffusion of categories over 50 steps (cosine schedule);
# one MLP predicts the noise and the categories' x₀ from [xₜ, one-hot xₜ, time embedding].
HIDDEN = [int(u) for u in [64, 64]]
synth, facts, hist, by_t = neural.fit_diffusion(
train, N_OUT, HIDDEN,
steps=50,
epochs=100,
batch_size=128,
lr=0.002,
time_dim=16,
seed=SEED,
)
history = pd.DataFrame([{k: v for k, v in h.items() if k != "valid_loss"} for h in hist])
HAS_NUM = any(not c.coded for c in train)
HAS_CAT = any(c.coded for c in train)
last = max(1, len(hist) // 10) # the last 10% of epochs
fit_values["steps"] = facts["steps"]
fit_values["batch_size"] = facts["batch_size"]
fit_values["final_loss"] = float(np.mean([h["loss"] for h in hist[-last:]]))
if HAS_NUM:
fit_values["loss_num"] = float(np.mean([h["loss_num"] for h in hist[-last:]]))
if HAS_CAT:
fit_values["loss_cat"] = float(np.mean([h["loss_cat"] for h in hist[-last:]]))
model_note = " with a diffusion model"
ep = history["epoch"].tolist()
parts = [("total", "loss")] + ([("Gaussian (numbers)", "loss_num")] if HAS_NUM else []) + ([("multinomial (categories)", "loss_cat")] if HAS_CAT else [])
extra_charts.append(cs.chart("training", "training-components", "Denoising loss by epoch", {
"x": cs.col("Epoch", ep * len(parts), "numeric"),
"value": cs.col("Loss", [v for _, k in parts for v in history[k].tolist()], "numeric"),
"component": cs.col("Part", [p for p, _ in parts for _ in ep], "categorical", levels=[p for p, _ in parts]),
}))
t_parts = ([("Gaussian (numbers)", 1)] if HAS_NUM else []) + ([("multinomial (categories)", 2)] if HAS_CAT else [])
extra_charts.append(cs.chart("timesteps", "timestep-loss", "Denoising loss by diffusion step", {
"t": cs.col("Diffusion step t", [r[0] for _, _ in t_parts for r in by_t], "numeric"),
"value": cs.col("Loss", [r[j] for _, j in t_parts for r in by_t], "numeric"),
"component": cs.col("Part", [p for p, _ in t_parts for _ in by_t], "categorical", levels=[p for p, _ in t_parts]),
}, note="Small t is almost clean data (a fine-detail task); large t is almost pure noise."))
for tt, ln, lc in by_t:
if HAS_NUM:
fit_values[f"loss_t_num[{tt}]"] = ln
if HAS_CAT:
fit_values[f"loss_t_cat[{tt}]"] = lc
finite = bool(np.all(np.isfinite(history["loss"].to_numpy())))
assumptions.append({
"key": "training_stable",
"label": "Training stayed finite",
"status": "pass" if finite else "fail",
"detail": f"The loss over the last 10% of epochs averaged {fit_values['final_loss']:.3g}." if finite else "A loss became infinite or undefined; lower the learning rate.",
})
sy.add_missing(synth, train, rng, "keep_rate") # each column's missing share, at random
# %% Write and compare
out = out_dir("target/academy-parity/run-8142/synth.diffusion/customers_all/out-python")
path = sy.write(os.path.join(out, "synthetic.parquet"), synth)
split = sy.write_split(os.path.join(out, "split.parquet"), n_input, train_rows, holdout_rows)
history.to_parquet(os.path.join(out, "history.parquet"), index=False)
values, table, charts = sy.summarize(train, synth, len(train_rows), n_input, len(holdout_rows), fit_values)
assumptions.append({
"key": "no_copies",
"label": "No synthetic row copies a training row",
"status": "pass" if values["exact_matches"] == 0 else "warn",
"detail": f"{values['exact_matches']:,} synthetic row{'s are' if values['exact_matches'] != 1 else ' is'} identical to a training row; the scorecard's distance to closest record checks near-copies.",
})
# Fidelity (Stage 12.10): judged on the mean column distances, the scorecard's column fidelity (good at ≥ 0.9 = 1 − 0.1).
fid_parts = []
if not np.isnan(values["fidelity_ks_mean"]):
fid_parts.append((values["fidelity_ks_mean"], f"numeric columns {values['fidelity_ks_mean']:.3f} (mean Kolmogorov–Smirnov distance)"))
if not np.isnan(values["fidelity_tv_mean"]):
fid_parts.append((values["fidelity_tv_mean"], f"categories {values['fidelity_tv_mean']:.3f} (mean total variation)"))
fid_worst = max((d for d, _ in fid_parts), default=None)
assumptions.append({
"key": "fidelity",
"label": "Synthetic columns match the data",
"status": "info" if fid_worst is None else ("pass" if fid_worst <= 0.1 else "warn"),
"detail": "No column could be compared with the data." if fid_worst is None else
"Distance from the training rows: " + "; ".join(t for _, t in fid_parts)
+ (" — at most 0.10, which the Synthetic studio's scorecard rates as good column fidelity." if fid_worst <= 0.1 else
" — above 0.10, so some columns' distributions differ visibly from the data; the scorecard shows which columns and pairs."),
})
summary = (
f"{values['n_rows']:,} synthetic rows over {len(COLUMNS)} column{'s' if len(COLUMNS) != 1 else ''} from "
f"{len(train_rows):,} training rows{model_note}."
)
if not np.isnan(values["fidelity_ks_mean"]):
summary += f" Numeric columns differ from the data by a mean Kolmogorov–Smirnov distance of {values['fidelity_ks_mean']:.3f}"
summary += f" and categories by a mean total variation of {values['fidelity_tv_mean']:.3f}." if not np.isnan(values["fidelity_tv_mean"]) else "."
elif not np.isnan(values["fidelity_tv_mean"]):
summary += f" Categories differ from the data by a mean total variation of {values['fidelity_tv_mean']:.3f}."
if values["exact_matches"]:
summary += f" {values['exact_matches']:,} synthetic row{'s are' if values['exact_matches'] != 1 else ' is'} identical to a training row."
cs.publish({
"title": "Synthetic data — tabular diffusion (TabDDPM-style)",
"engine": cs.engine_info("torch", "scipy", "pyarrow", "numpy", "pyarrow"),
"n": values["n_real"],
"summary": summary,
"statistics": [
{"key": "n_rows", "label": "Synthetic rows", "value": values["n_rows"], "format": "integer"},
{"key": "fidelity_ks_mean", "label": "Mean KS distance", "value": values.get("fidelity_ks_mean")},
{"key": "fidelity_tv_mean", "label": "Mean TV distance", "value": values.get("fidelity_tv_mean")},
{"key": "exact_matches", "label": "Rows copied from the data", "value": values["exact_matches"], "format": "integer"},
],
"tables": [table, *extra_tables],
"values": values,
"charts": charts + extra_charts,
"assumptions": assumptions,
"warnings": warnings,
"artifacts": [
{"key": "synthetic", "path": path, "format": "parquet", "title": "Synthetic rows"},
{"key": "split", "path": split, "format": "parquet", "title": "Training and holdout rows"},
{"key": "history", "path": os.path.join(out, "history.parquet"), "format": "parquet", "title": "Training history"},
],
"model": {"kind": "generator", "columns": COLUMNS, "params": {
"n_rows": None,
"steps": 50,
"hidden_layers": [64, 64],
"epochs": 100,
"batch_size": 128,
"learning_rate": 0.002,
"time_dim": 16,
"missing": "keep_rate",
"holdout": 0.2,
}},
})
Check: latent diffusion and DiT
CheckpointCheck yourself
Why run diffusion on an autoencoder's codes?
Show the answer
Answer: a
The heavy, repeated work happens in the small code space; the decoder runs once per sample.
Check yourself
What sets an upper limit on a latent diffusion model's sample quality?
Show the answer
Answer: b
Diffusion produces codes, and the frozen decoder turns them into items. Its rebuild quality is a ceiling.
Check yourself
How does a Diffusion Transformer take in the diffusion step and the class condition?
Show the answer
Answer: b
adaLN maps the step and condition to a scale and shift for each normalized layer; adaLN-Zero adds zero-initialized residual gates.
Check yourself
What does the "Zero" in adaLN-Zero refer to?
Show the answer
Answer: a
Starting each block as the identity makes deep transformer denoisers easier to train.
Recap
Recap- Latent diffusion trains an autoencoder, then diffuses its codes and decodes once at the end.
- The autoencoder's rebuild quality caps the samples; check it on held-out items first.
- A Diffusion Transformer denoises patch tokens; the step and condition enter through adaLN.
- CodeSplash diffuses tables in data space; latent diffusion and DiT are explained here.
Concepts in this lesson