Skip to content

bodin-e/linear-combinations-of-latents

Repository files navigation

Linear combinations of latents in generative models: subspaces and beyond

This repository provides an implementation of LOL (Latent Optimal Linear combinations), as presented in the paper:

Linear Combinations of Latents in Generative Models: Subspaces and Beyond

Alt text

Abstract

Sampling from generative models has become a crucial tool for applications like data synthesis and augmentation. Diffusion, Flow Matching and Continuous Normalizing Flows have shown effectiveness across various modalities, and rely on latent variables for generation. For experimental design or creative applications that require more control over the generation process, it has become common to manipulate the latent variable directly. However, existing approaches for performing such manipulations (e.g. interpolation or forming low-dimensional representations) only work well in special cases or are network or data-modality specific. We propose Latent Optimal Linear combinations (LOL) as a general-purpose method to form linear combinations of latent variables that adhere to the assumptions of the generative model. As LOL is easy to implement and naturally addresses the broader task of forming any linear combinations, e.g. the construction of subspaces of the latent space, LOL dramatically simplifies the creation of expressive low-dimensional representations of high-dimensional objects.

Installation

pip install lolatents

Usage

To see the LOL method in use, please see the provided example notebooks:

from lolatents.lol_numpy import lol_iid
# from lolatents.lol_torch import lol_iid # for PyTorch

latents = lol_iid(
  w=linear_combination_weights,
  X=seed_latents,
  cdf=latent_distribution.cdf,
  inverse_cdf=latent_distribution.ppf
)

About

Implementation of LOL from "Linear Combinations of Latents in Generative Models: Subspaces and Beyond"

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published