JPEG Compression as a Differentiable PyTorch Module

Most autoencoders learn their representations from data. That’s powerful, but opaque — you can’t easily reason about what each latent dimension means, or guarantee invertibility. JPEG takes the opposite approach. Its encoding is a fixed, well-understood signal-processing pipeline. I’ve always found that contrast interesting, so I built dct-autoencoder — a PyTorch module that implements the core JPEG pipeline analytically, without any training. The motivation A question I kept running into doing computer vision work: why do we process images in RGB? ...

June 6, 2026 · 6 min · Dariush