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

Overview

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

Example

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()

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 our repository and arXiv preprint 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}},
  eprint={2112.10638},
  archivePrefix={arXiv},
  primaryClass={cs.LG},
  url = {https://github.com/karnwatcharasupat/latte}
  doi = {10.5281/zenodo.5786402}
}
Comments
  • Documentation: Metric Descriptions

    Documentation: Metric Descriptions

    Might be nice to provide a short description for each metric in addition to the paper links. The readme might get too long with it, but either some doc in the repo or maybe on a github.io page?

    type: documentation priority: high 
    opened by alexanderlerch 2
  • Add Smoothness and Monotonicity support

    Add Smoothness and Monotonicity support

    Smoothness

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests

    Monotonicity

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add Modularity support

    Add Modularity support

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add SAP support

    Add SAP support

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add DMIG, DLIG, XMIG support

    Add DMIG, DLIG, XMIG support

    DMIG

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests

    XMIG

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests

    DLIG

    • [ x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Add MIG support

    Add MIG support

    • [x] Functional API
      • [x] implementation
      • [x] tests
    • [x] Base API
      • [x] implementation
      • [x] tests
    • [x] Torch API
      • [x] implementation
      • [x] tests
    • [x] Keras API
      • [x] implementation
      • [x] tests
    type: enhancement 
    opened by karnwatcharasupat 0
  • Support issue for on-the-fly computation in TF2 graph mode

    Support issue for on-the-fly computation in TF2 graph mode

    The current delegate-to-NumPy technique used in TF is only compatible with TF2 eager mode since Tensor.numpy() would not work in graph mode. As a result, graph-mode users will only be able to use Latte in the evaluation stage when the model weights are no longer changing but not on-the-fly during the training stage.

    However, certain computation steps required for some metrics (especially MI-based ones) necessarily require scikit-learn ops and there is no (maintainable) way to create consistent TF mirrors of those functions.

    One potential solution is to wrap the core functions in tf.numpy_function or tf.py_function but we will have to figure out a way to make the wrapper less painful to implement/maintain since the variable args/kwargs option currently used by the dtype converter is not allowed in these functions. A naive workaround would be to make a tf.numpy_function wrapper for every highest-possible level function with fixed args but this would be considered a last-resort solution.

    Links:

    • https://www.tensorflow.org/api_docs/python/tf/numpy_function
    • https://www.tensorflow.org/api_docs/python/tf/py_function
    type: enhancement priority: medium !! needs more brains !! 
    opened by karnwatcharasupat 3
Releases(v0.0.1-alpha5)
  • v0.0.1-alpha5(Jan 20, 2022)

    What's Changed

    • Add contributing guide by @karnwatcharasupat in https://github.com/karnwatcharasupat/latte/pull/16
    • [ADD] add example notebooks by @karnwatcharasupat in https://github.com/karnwatcharasupat/latte/pull/18

    Full Changelog: https://github.com/karnwatcharasupat/latte/compare/v0.0.1-alpha3...v0.0.1-alpha5

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1-alpha3(Dec 16, 2021)

  • v0.0.1-alpha2(Dec 9, 2021)

  • v0.0.1-alpha1(Dec 1, 2021)

Owner
Karn Watcharasupat
Lab Cat 🐱🌈 | Audio Signal Processing Research Student. NTU EEE Class of 2022. Georgia Tech Music Tech Visiting Researcher.
Karn Watcharasupat
Boundary-aware Transformers for Skin Lesion Segmentation

Boundary-aware Transformers for Skin Lesion Segmentation Introduction This is an official release of the paper Boundary-aware Transformers for Skin Le

Jiacheng Wang 79 Dec 16, 2022
OcclusionFusion: realtime dynamic 3D reconstruction based on single-view RGB-D

OcclusionFusion (CVPR'2022) Project Page | Paper | Video Overview This repository contains the code for the CVPR 2022 paper OcclusionFusion, where we

Wenbin Lin 193 Dec 15, 2022
PyTorch implementation of Asymmetric Siamese (https://arxiv.org/abs/2204.00613)

Asym-Siam: On the Importance of Asymmetry for Siamese Representation Learning This is a PyTorch implementation of the Asym-Siam paper, CVPR 2022: @inp

Meta Research 89 Dec 18, 2022
Localized representation learning from Vision and Text (LoVT)

Localized Vision-Text Pre-Training Contrastive learning has proven effective for pre- training image models on unlabeled data and achieved great resul

Philip MΓΌller 10 Dec 07, 2022
A very tiny, very simple, and very secure file encryption tool.

Picocrypt is a very tiny (hence "Pico"), very simple, yet very secure file encryption tool. It uses the modern ChaCha20-Poly1305 cipher suite as well

Evan Su 1k Dec 30, 2022
A scanpy extension to analyse single-cell TCR and BCR data.

Scirpy: A Scanpy extension for analyzing single-cell immune-cell receptor sequencing data Scirpy is a scalable python-toolkit to analyse T cell recept

ICBI 145 Jan 03, 2023
Implementation of H-Transformer-1D, Hierarchical Attention for Sequence Learning using πŸ€— transformers

hierarchical-transformer-1d Implementation of H-Transformer-1D, Hierarchical Attention for Sequence Learning using πŸ€— transformers In Progress!! 2021.

MyungHoon Jin 7 Nov 06, 2022
PyTorch deep learning projects made easy.

PyTorch Template Project PyTorch deep learning project made easy. PyTorch Template Project Requirements Features Folder Structure Usage Config file fo

Victor Huang 3.8k Jan 01, 2023
Deep learning with dynamic computation graphs in TensorFlow

TensorFlow Fold TensorFlow Fold is a library for creating TensorFlow models that consume structured data, where the structure of the computation graph

1.8k Dec 28, 2022
Emulation and Feedback Fuzzing of Firmware with Memory Sanitization

BaseSAFE This repository contains the BaseSAFE Rust APIs, introduced by "BaseSAFE: Baseband SAnitized Fuzzing through Emulation". The example/ directo

Security in Telecommunications 138 Dec 16, 2022
Official Repsoitory for "Activate or Not: Learning Customized Activation." [CVPR 2021]

CVPR 2021 | Activate or Not: Learning Customized Activation. This repository contains the official Pytorch implementation of the paper Activate or Not

184 Dec 27, 2022
HackBMU-5.0-Team-Ctrl-Alt-Elite - HackBMU 5.0 Team Ctrl Alt Elite

HackBMU-5.0-Team-Ctrl-Alt-Elite The search is over. We present to you β€˜Health-A-

3 Feb 19, 2022
Shitty gaze mouse controller

demo.mp4 shitty_gaze_mouse_cotroller install tensofflow, cv2 run the main.py and as it starts it will collect data so first raise your left eyebrow(bo

16 Aug 30, 2022
An implementation of an abstract algebra for music tones (pitches).

nbdev template Use this template to more easily create your nbdev project. If you are using an older version of this template, and want to upgrade to

Open Music Kit 0 Oct 10, 2022
A PyTorch Implementation of Single Shot MultiBox Detector

SSD: Single Shot MultiBox Object Detector, in PyTorch A PyTorch implementation of Single Shot MultiBox Detector from the 2016 paper by Wei Liu, Dragom

Max deGroot 4.8k Jan 07, 2023
Jittor implementation of Recursive-NeRF: An Efficient and Dynamically Growing NeRF

Recursive-NeRF: An Efficient and Dynamically Growing NeRF This is a Jittor implementation of Recursive-NeRF: An Efficient and Dynamically Growing NeRF

33 Nov 30, 2022
OpenDelta - An Open-Source Framework for Paramter Efficient Tuning.

OpenDelta is a toolkit for parameter efficient methods (we dub it as delta tuning), by which users could flexibly assign (or add) a small amount parameters to update while keeping the most paramters

THUNLP 386 Dec 26, 2022
[ICCV'2021] Image Inpainting via Conditional Texture and Structure Dual Generation

[ICCV'2021] Image Inpainting via Conditional Texture and Structure Dual Generation

Xiefan Guo 122 Dec 11, 2022
Code accompanying our NeurIPS 2021 traffic4cast challenge

Traffic forecasting on traffic movie snippets This repo contains all code to reproduce our approach to the IARAI Traffic4cast 2021 challenge. In the c

Nina Wiedemann 2 Aug 09, 2022
[NeurIPS-2021] Slow Learning and Fast Inference: Efficient Graph Similarity Computation via Knowledge Distillation

Efficient Graph Similarity Computation - (EGSC) This repo contains the source code and dataset for our paper: Slow Learning and Fast Inference: Effici

23 Nov 11, 2022