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
NanoDet-PlusโšกSuper fast and lightweight anchor-free object detection model. ๐Ÿ”ฅOnly 980 KB(int8) / 1.8MB (fp16) and run 97FPS on cellphone๐Ÿ”ฅ

NanoDet-PlusโšกSuper fast and lightweight anchor-free object detection model. ๐Ÿ”ฅOnly 980 KB(int8) / 1.8MB (fp16) and run 97FPS on cellphone๐Ÿ”ฅ

4.8k Jan 07, 2023
D2Go is a toolkit for efficient deep learning

D2Go D2Go is a production ready software system from FacebookResearch, which supports end-to-end model training and deployment for mobile platforms. W

Facebook Research 744 Jan 04, 2023
RM Operation can equivalently convert ResNet to VGG, which is better for pruning; and can help RepVGG perform better when the depth is large.

RM Operation can equivalently convert ResNet to VGG, which is better for pruning; and can help RepVGG perform better when the depth is large.

184 Jan 04, 2023
Graph Posterior Network: Bayesian Predictive Uncertainty for Node Classification (NeurIPS 2021)

Graph Posterior Network This is the official code repository to the paper Graph Posterior Network: Bayesian Predictive Uncertainty for Node Classifica

Maximilian Stadler 30 Dec 05, 2022
AI4Good project for detecting waste in the environment

Detect waste AI4Good project for detecting waste in environment. www.detectwaste.ml. Our latest results were published in Waste Management journal in

108 Dec 25, 2022
LexGLUE: A Benchmark Dataset for Legal Language Understanding in English

LexGLUE: A Benchmark Dataset for Legal Language Understanding in English โš–๏ธ ๐Ÿ† ๐Ÿง‘โ€๐ŸŽ“ ๐Ÿ‘ฉโ€โš–๏ธ Dataset Summary Inspired by the recent widespread use of th

95 Dec 08, 2022
piSTAR Lab is a modular platform built to make AI experimentation accessible and fun. (pistar.ai)

piSTAR Lab WARNING: This is an early release. Overview piSTAR Lab is a modular deep reinforcement learning platform built to make AI experimentation a

piSTAR Lab 0 Aug 01, 2022
LF-YOLO (Lighter and Faster YOLO) is used to detect defect of X-ray weld image.

This project is based on ultralytics/yolov3. LF-YOLO (Lighter and Faster YOLO) is used to detect defect of X-ray weld image. The related paper is avai

26 Dec 13, 2022
PyTorch implementation of DUL (Data Uncertainty Learning in Face Recognition, CVPR2020)

PyTorch implementation of DUL (Data Uncertainty Learning in Face Recognition, CVPR2020)

Mouxiao Huang 20 Nov 15, 2022
ConvMixer unofficial implementation

ConvMixer ConvMixer ้žๅฎ˜ๆ–นๅฎž็Žฐ pytorch ็‰ˆๆœฌๅทฒ็ปๅฎž็Žฐใ€‚ nets ๆ˜ฏ้‡ๆž„็‰ˆๆœฌ ๏ผŒtest ๆ˜ฏๅฎ˜ๆ–นไปฃ็  ๆ„Ÿๅ…ด่ถฃๅฐไผ™ไผดๅฏไปฅๅฏน็…ง็œ‹ไธ€ไธ‹ใ€‚ keras ๅทฒ็ปๅฎž็Žฐ tf2.x ไธญ ๆ˜ฏtensorflow 2 ็‰ˆๆœฌ gelu ๆฟ€ๆดปๅ‡ฝๆ•ฐ่ฆๆฑ‚ tf=2.4 ๅฆๅˆ™ไฝฟ็”จๅ…ฅไธ‹ไปฃ็ ไปฃๆ›ฟgelu

Jian Tengfei 8 Jul 11, 2022
a reimplementation of Holistically-Nested Edge Detection in PyTorch

pytorch-hed This is a personal reimplementation of Holistically-Nested Edge Detection [1] using PyTorch. Should you be making use of this work, please

Simon Niklaus 375 Dec 06, 2022
shufflev2-yolov5๏ผšlighter, faster and easier to deploy

shufflev2-yolov5: lighter, faster and easier to deploy. Evolved from yolov5 and the size of model is only 1.7M (int8) and 3.3M (fp16). It can reach 10+ FPS on the Raspberry Pi 4B when the input size

pogg 1.5k Jan 05, 2023
A PaddlePaddle implementation of STGCN with a few modifications in the model architecture in order to forecast traffic jam.

About This repository contains the code of a PaddlePaddle implementation of STGCN based on the paper Spatio-Temporal Graph Convolutional Networks: A D

Tianjian Li 1 Jan 11, 2022
Implementation of "Glancing Transformer for Non-Autoregressive Neural Machine Translation"

GLAT Implementation for the ACL2021 paper "Glancing Transformer for Non-Autoregressive Neural Machine Translation" Requirements Python = 3.7 Pytorch

117 Jan 09, 2023
This repository is an open-source implementation of the ICRA 2021 paper: Locus: LiDAR-based Place Recognition using Spatiotemporal Higher-Order Pooling.

Locus This repository is an open-source implementation of the ICRA 2021 paper: Locus: LiDAR-based Place Recognition using Spatiotemporal Higher-Order

Robotics and Autonomous Systems Group 96 Dec 15, 2022
Implementation of PersonaGPT Dialog Model

PersonaGPT An open-domain conversational agent with many personalities PersonaGPT is an open-domain conversational agent cpable of decoding personaliz

ILLIDAN Lab 42 Jan 01, 2023
This repository contains a toolkit for collecting, labeling and tracking object keypoints

This repository contains a toolkit for collecting, labeling and tracking object keypoints. Object keypoints are semantic points in an object's coordinate frame.

ETHZ ASL 13 Dec 12, 2022
A Pytorch implementation of CVPR 2021 paper "RSG: A Simple but Effective Module for Learning Imbalanced Datasets"

RSG: A Simple but Effective Module for Learning Imbalanced Datasets (CVPR 2021) A Pytorch implementation of our CVPR 2021 paper "RSG: A Simple but Eff

120 Dec 12, 2022
CVPR2022 paper "Dense Learning based Semi-Supervised Object Detection"

[CVPR2022] DSL: Dense Learning based Semi-Supervised Object Detection DSL is the first work on Anchor-Free detector for Semi-Supervised Object Detecti

Bhchen 69 Dec 08, 2022