liveBook · Manning

Encoding arithmetic

As explained in Learn Generative AI with PyTorch

A latent-space manipulation method that adds and subtracts VAE encodings to synthesize new outputs.

Encoding arithmetic manipulates a variational autoencoder’s latent representations by adding and subtracting averaged encodings, then decoding the result into a new image. A regularized latent space makes related features sufficiently continuous and interpretable for this operation. section 7.4.4

Removing glasses through latent arithmetic

Let z1 represent men with glasses, z2 women with glasses, and z3 women without glasses. Compute z = z1 − z2 + z3, then decode z to target a man-without-glasses image.

Encoding arithmetic differs from encoding interpolation: arithmetic targets a feature transformation, whereas interpolation gradually blends two encodings by changing a weight from 0 to 1.

How Learn Generative AI with PyTorch covers it

How deep it goes
Explains group selection, encoding averages, latent arithmetic, and decoding, while stopping short of mathematical derivation.
Examples
Uses groups of people with or without glasses and demonstrates a man-with-glasses minus woman-with-glasses plus woman-without-glasses transformation.
What it assumes
Assumes a trained VAE with encoder and decoder components, while teaching latent manipulation through concrete image groups.
What you can do after
Apply it via PyTorch by averaging group encodings, combining them algebraically, and decoding the resulting latent vector.
How it connects
Connects variational autoencoders, latent space, encoder, decoder, KL divergence, and encoding interpolation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Generative AI with PyTorch. The section links point to the parts of the book it draws on.