Toolkit to form subspaces of latent spaces and more in diffusion models and other latent variable models.
Project description
Linear combinations of latents in generative models: subspaces and beyond
This repository provides an implementation of LOL (Linear combinations Of Latent variables), as presented in the paper:
Linear Combinations of Latents in Generative Models: Subspaces and Beyond
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 Linear combinations of Latent variables (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.
Usage
To 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=w_grid_including_remaining,
X=seed_latents,
cdf=latent_distribution.cdf,
inverse_cdf=latent_distribution.ppf
)
Installation
To use this repository, clone it and install dependencies:
git clone https://github.com/bodin-e/linear-combinations-of-latents.git
cd linear-combinations-of-latents
pip install -r requirements.txt
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lolatents-0.1.1.tar.gz.
File metadata
- Download URL: lolatents-0.1.1.tar.gz
- Upload date:
- Size: 5.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7db680f1902d27fe3979c9167cc1b649dabd0b0c4f243241f0aaa2ac34117ab1
|
|
| MD5 |
e094bfd88b82c89ab2d0b92f2a3e3bd3
|
|
| BLAKE2b-256 |
ef8c71052856833bc04ef629d13095113c6ddcca00a365c3e3cb7766575f936d
|
File details
Details for the file lolatents-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lolatents-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38e5fb50dc88b63d7c2f844f572d0768d01b30fb40d785ac59b9180b377203b4
|
|
| MD5 |
9dfc6195da7a474496dd1b420ed01617
|
|
| BLAKE2b-256 |
ad90b97f5aa6dc1988774890ecca03e0711c45ba36accec520db83b437fb37d2
|