Skip to main content

A Python library for discrete variables relaxation

Project description

Just Relax It

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 1
  5. Blog Post 2
  6. Documentation
  7. Tests
  8. Technical Report

💡 Motivation

For lots of mathematical problems we need an ability to sample discrete random variables. The problem is that due to continuous nature of deep learning optimization, the usage of truly discrete random variables is infeasible. Thus we use different relaxation methods. 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 via pip

pip install relaxit

Install from source

pip install git+https://github.com/intsystems/relaxit

Install via Git clone

git clone https://github.com/intsystems/relaxit
cd relaxit
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.

[^*]: We also implement REINFORCE algorithm as a score function estimator alternative for our relaxation methods that are inherently pathwise derivative estimators. This one is implemented only for demo experiments and is not included into the source code of package.

📚 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

🔗 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-1.2.0.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

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

relaxit-1.2.0-py3-none-any.whl (24.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: relaxit-1.2.0.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for relaxit-1.2.0.tar.gz
Algorithm Hash digest
SHA256 f66438f76099a75b5a28e8734866491b987fba7a773f1905b522bff5e53b6e1b
MD5 94bd9e8fec2167b4c57c473578621b39
BLAKE2b-256 e48b5d4f715d9e024e7a5521c25c801cb08c9c23a7cf17b2123cc06cda008b0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for relaxit-1.2.0.tar.gz:

Publisher: pypi.yml on intsystems/relaxit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: relaxit-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 24.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for relaxit-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fdf4a489dae08720e615aebcf906e6b46c186d11e1095c60929e4e726db3e743
MD5 e13b5b2a0b1cabb5516f43249beef542
BLAKE2b-256 c0f0c413a34a360a8b50c229554a48ecf186c1b18e7e7a728ab39e564c021382

See more details on using hashes here.

Provenance

The following attestation bundles were made for relaxit-1.2.0-py3-none-any.whl:

Publisher: pypi.yml on intsystems/relaxit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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