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
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.
pip install lolatentsTo see the LOL method in use, please see the provided example notebooks:
example_interpolation.ipynb– Demonstrates simple interpolation.example_subspace.ipynb– Illustrates how latent subspaces can be defined.example_grid.ipynb– Similar as above but directly using linear combination weights.
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
)