Skip to main content

Latte: Cross-framework Python Package for Evaluation of Latent-based Generative Models

Project description

Cross-framework Python Package for Evaluation of Latent-based Generative Models

Documentation Status CircleCI codecov CodeFactor License PyPI version DOI arXiv

Latte

Latte (for LATent Tensor Evaluation) is a cross-framework Python package for evaluation of latent-based generative models. Latte supports calculation of disentanglement and controllability metrics in both PyTorch (via TorchMetrics) and TensorFlow.

Installation

For developers working on local clone, cd to the repo and replace latte with .. For example, pip install .[tests]

pip install latte-metrics           # core (numpy only)
pip install latte-metrics[pytorch]  # with torchmetrics wrapper
pip install latte-metrics[keras]    # with tensorflow wrapper
pip install latte-metrics[tests]    # for testing

Running tests locally

pip install .[tests]
pytest tests/ --cov=latte

Quick Examples

Functional API

import latte
from latte.functional.disentanglement.mutual_info import mig
import numpy as np

latte.seed(42)

z = np.random.randn(16, 8)
a = np.random.randn(16, 2)

mutual_info_gap = mig(z, a, discrete=False, reg_dim=[4, 3])

Modular API

import latte
from latte.metrics.core.disentanglement import MutualInformationGap
import numpy as np

latte.seed(42)

mig = MutualInformationGap()

# ... 
# initialize data and model
# ...

for data, attributes in range(batches):
  recon, z = model(data)

  mig.update_state(z, attributes)

mig_val = mig.compute()

TorchMetrics API

import latte
from latte.metrics.torch.disentanglement import MutualInformationGap
import torch

latte.seed(42)

mig = MutualInformationGap()

# ... 
# initialize data and model
# ...

for data, attributes in range(batches):
  recon, z = model(data)

  mig.update(z, attributes)

mig_val = mig.compute()

Keras Metric API

import latte
from latte.metrics.keras.disentanglement import MutualInformationGap
from tensorflow import keras as tfk

latte.seed(42)

mig = MutualInformationGap()

# ... 
# initialize data and model
# ...

for data, attributes in range(batches):
  recon, z = model(data)

  mig.update_state(z, attributes)

mig_val = mig.result()

Example Notebooks

See Latte in action with Morpho-MNIST example notebooks on Google Colab:

Documentation

https://latte.readthedocs.io/en/latest

Supported metrics

๐Ÿงช Beta support | โœ”๏ธ Stable | ๐Ÿ”จ In Progress | ๐Ÿ•ฃ In Queue | ๐Ÿ‘€ KIV |

Metric Latte Functional Latte Modular TorchMetrics Keras Metric
Disentanglement Metrics
๐Ÿ“ Mutual Information Gap (MIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Dependency-blind Mutual Information Gap (DMIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Dependency-aware Mutual Information Gap (XMIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Dependency-aware Latent Information Gap (DLIG) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Separate Attribute Predictability (SAP) ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Modularity ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ ฮฒ-VAE Score ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ FactorVAE Score ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ DCI Score ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ Interventional Robustness Score (IRS) ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ Consistency ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
๐Ÿ“ Restrictiveness ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€
Interpolatability Metrics
๐Ÿ“ Smoothness ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Monotonicity ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช
๐Ÿ“ Latent Density Ratio ๐Ÿ•ฃ ๐Ÿ•ฃ ๐Ÿ•ฃ ๐Ÿ•ฃ
๐Ÿ“ Linearity ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€ ๐Ÿ‘€

Bundled metric modules

๐Ÿงช Experimental (subject to changes) | โœ”๏ธ Stable | ๐Ÿ”จ In Progress | ๐Ÿ•ฃ In Queue

Metric Bundle Latte Functional Latte Modular TorchMetrics Keras Metric Included
Dependency-aware Disentanglement ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช MIG, DMIG, XMIG, DLIG
LIAD-based Interpolatability ๐Ÿงช ๐Ÿงช ๐Ÿงช ๐Ÿงช Smoothness, Monotonicity

Cite

For individual metrics, please cite the paper according to the link in the ๐Ÿ“ icon in front of each metric.

If you find our package useful, please cite open access paper on Software Impacts (Elsevier) as

@article{
  watcharasupat2021latte,
  author = {Watcharasupat, Karn N. and Lee, Junyoung and Lerch, Alexander},
  title = {{Latte: Cross-framework Python Package for Evaluation of Latent-based Generative Models}},
  journal = {Software Impacts},
  volume = {11},
  pages = {100222},
  year = {2022},
  issn = {2665-9638},
  doi = {https://doi.org/10.1016/j.simpa.2022.100222},
  url = {https://www.sciencedirect.com/science/article/pii/S2665963822000033},
}

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

latte-metrics-0.0.1a6.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

latte_metrics-0.0.1a6-py3-none-any.whl (52.6 kB view details)

Uploaded Python 3

File details

Details for the file latte-metrics-0.0.1a6.tar.gz.

File metadata

  • Download URL: latte-metrics-0.0.1a6.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for latte-metrics-0.0.1a6.tar.gz
Algorithm Hash digest
SHA256 588de376b508fba930ac9d25ad81ca1bcd4dca4274487e06ef56d5131e61db1f
MD5 1921a056cf8236318c8aa75538486fce
BLAKE2b-256 11b27047fd75d4c67c10cac20dcd7ca5c11b7768ef830cb869ed73b19af0f8cb

See more details on using hashes here.

File details

Details for the file latte_metrics-0.0.1a6-py3-none-any.whl.

File metadata

File hashes

Hashes for latte_metrics-0.0.1a6-py3-none-any.whl
Algorithm Hash digest
SHA256 de87d2265306bdfc6e74d6e0a40ce95f79a50ae477f7aff17c16f5dbe3b01607
MD5 a38cb151447728218024f9a4a0846c77
BLAKE2b-256 809cccc0fc8920cdf15cf498e6e7ee3ff8f68cd3c74a404591ae53f051d714ab

See more details on using hashes here.

Supported by

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