Skip to main content

A Python library for discrete variables relaxation

Project description

Just Relax It

Discrete Variables Relaxation

Compatible with PyTorch Inspired by Pyro

Coverage_2 Coverage Docs

License GitHub Contributors Issues GitHub Pull Requests

"Just Relax It" is a cutting-edge Python library designed to streamline the optimization of discrete probability distributions in neural networks, offering a suite of advanced relaxation techniques compatible with PyTorch.

📬 Assets

  1. Technical Meeting 1 - Presentation
  2. Technical Meeting 2 - Jupyter Notebook
  3. Technical Meeting 3 - Jupyter Notebook
  4. Blog Post
  5. Documentation
  6. Tests

💡 Motivation

For lots of mathematical problems we need an ability to sample discrete random variables. The problem is that due to continuos nature of deep learning optimization, the usage of truely discrete random variables is infeasible. Thus we use different relaxation method. One of them, Concrete distribution or Gumbel-Softmax (this is one distribution proposed in parallel by two research groups) is implemented in different DL packages. In this project we implement different alternatives to it.

🗃 Algorithms

🛠️ Install

Install using pip

pip install relaxit

Install from source

pip install git+https://github.com/intsystems/discrete-variables-relaxation

Install via Git clone

git clone https://github.com/intsystems/discrete-variables-relaxation
cd discrete-variables-relaxation
pip install -e .

🚀 Quickstart

Open In Colab

import torch
from relaxit.distributions import InvertibleGaussian

# initialize distribution parameters
loc = torch.zeros(3, 4, 5, requires_grad=True)
scale = torch.ones(3, 4, 5, requires_grad=True)
temperature = torch.tensor([1e-0])

# initialize distribution
distribution = InvertibleGaussian(loc, scale, temperature)

# sample with reparameterization
sample = distribution.rsample()
print('sample.shape:', sample.shape)
print('sample.requires_grad:', sample.requires_grad)

🎮 Demo

Laplace Bridge REINFORCE in Acrobot environment VAE with discrete latents
Laplace Bridge REINFORCE VAE
Open In Colab Open In Colab Open In Colab

For demonstration purposes, we divide our algorithms in three different groups. Each group relates to the particular demo code:

We describe our demo experiments here.

📚 Stack

Some of the alternatives for GS were implemented in pyro, so we base our library on their codebase.

🧩 Some details

To make to library consistent, we integrate imports of distributions from pyro and torch into the library, so that all the categorical distributions can be imported from one entrypoint.

👥 Contributors

  • Daniil Dorin (Basic code writing, Final demo, Algorithms)
  • Igor Ignashin (Project wrapping, Documentation writing, Algorithms)
  • Nikita Kiselev (Project planning, Blog post, Algorithms)
  • Andrey Veprikov (Tests writing, Documentation writing, Algorithms)
  • You are welcome to contribute to our project!

🔗 Useful links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

relaxit-0.1.3.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

relaxit-0.1.3-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file relaxit-0.1.3.tar.gz.

File metadata

  • Download URL: relaxit-0.1.3.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for relaxit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 73e6c3d641757e65695397ce41d8e447a527bb7bf58adcc0a0d296f19e99708f
MD5 156a2630082b52fca2ac88c3c1d49786
BLAKE2b-256 4de6f9a63a007d11bc1b82588d3aa2214122152d688e5149b35853ba95b24649

See more details on using hashes here.

File details

Details for the file relaxit-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: relaxit-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.15

File hashes

Hashes for relaxit-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3e913abd60963fb5c2c41de7b683e9d1b89ae2d92096344e8cf8af6cccbbfa27
MD5 0f319b10822a5bb8b949086b8220e00b
BLAKE2b-256 cd4786cd022d4a2aa6daa54bc3850f36a586fa50cd6573025bc9c869fe1d56fa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page