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
Code for ViTAS_Vision Transformer Architecture Search

Vision Transformer Architecture Search This repository open source the code for ViTAS: Vision Transformer Architecture Search. ViTAS aims to search fo

46 Dec 17, 2022
NCVX (NonConVeX): A User-Friendly and Scalable Package for Nonconvex Optimization in Machine Learning.

The source code is temporariy removed, as we are solving potential copyright and license issues with GRANSO (http://www.timmitchell.com/software/GRANS

SUN Group @ UMN 28 Aug 03, 2022
This repository contains codes of ICCV2021 paper: SO-Pose: Exploiting Self-Occlusion for Direct 6D Pose Estimation

SO-Pose This repository contains codes of ICCV2021 paper: SO-Pose: Exploiting Self-Occlusion for Direct 6D Pose Estimation This paper is basically an

shangbuhuan 52 Nov 25, 2022
Catbird is an open source paraphrase generation toolkit based on PyTorch.

Catbird is an open source paraphrase generation toolkit based on PyTorch. Quick Start Requirements and Installation The project is based on PyTorch 1.

Afonso Salgado de Sousa 5 Dec 15, 2022
A DNN inference latency prediction toolkit for accurately modeling and predicting the latency on diverse edge devices.

Note: This is an alpha (preview) version which is still under refining. nn-Meter is a novel and efficient system to accurately predict the inference l

Microsoft 244 Jan 06, 2023
A method that utilized Generative Adversarial Network (GAN) to interpret the black-box deep image classifier models by PyTorch.

A method that utilized Generative Adversarial Network (GAN) to interpret the black-box deep image classifier models by PyTorch.

Yunxia Zhao 3 Dec 29, 2022
A Deep Learning based project for creating line art portraits.

ArtLine The main aim of the project is to create amazing line art portraits. Sounds Intresting,let's get to the pictures!! Model-(Smooth) Model-(Quali

Vijish Madhavan 3.3k Jan 07, 2023
A collection of differentiable SVD methods and also the official implementation of the ICCV21 paper "Why Approximate Matrix Square Root Outperforms Accurate SVD in Global Covariance Pooling?"

Differentiable SVD Introduction This repository contains: The official Pytorch implementation of ICCV21 paper Why Approximate Matrix Square Root Outpe

YueSong 32 Dec 25, 2022
DANA paper supplementary materials

DANA Supplements This repository stores the data, results, and R scripts to generate these reuslts and figures for the corresponding paper Depth Norma

0 Dec 17, 2021
Deep learning (neural network) based remote photoplethysmography: how to extract pulse signal from video using deep learning tools

Deep-rPPG: Camera-based pulse estimation using deep learning tools Deep learning (neural network) based remote photoplethysmography: how to extract pu

Terbe Dรกniel 138 Dec 17, 2022
DeepStochlog Package For Python

DeepStochLog Installation Installing SWI Prolog DeepStochLog requires SWI Prolog to run. Run the following commands to install: sudo apt-add-repositor

KU Leuven Machine Learning Research Group 17 Dec 23, 2022
Official code for 'Pixel-wise Energy-biased Abstention Learning for Anomaly Segmentationon Complex Urban Driving Scenes'

PEBAL This repo contains the Pytorch implementation of our paper: Pixel-wise Energy-biased Abstention Learning for Anomaly Segmentationon Complex Urba

Yu Tian 115 Dec 29, 2022
i-SpaSP: Structured Neural Pruning via Sparse Signal Recovery

i-SpaSP: Structured Neural Pruning via Sparse Signal Recovery This is a public code repository for the publication: i-SpaSP: Structured Neural Pruning

Cameron Ronald Wolfe 5 Nov 04, 2022
TensorFlow implementation of "Attention is all you need (Transformer)"

[TensorFlow 2] Attention is all you need (Transformer) TensorFlow implementation of "Attention is all you need (Transformer)" Dataset The MNIST datase

YeongHyeon Park 4 Jan 05, 2022
Class-Attentive Diffusion Network for Semi-Supervised Classification [AAAI'21] (official implementation)

Class-Attentive Diffusion Network for Semi-Supervised Classification Official Implementation of AAAI 2021 paper Class-Attentive Diffusion Network for

Jongin Lim 7 Sep 20, 2022
Python lib to talk to pylontech lithium batteries (US2000, US3000, ...) using RS485

python-pylontech Python lib to talk to pylontech lithium batteries (US2000, US3000, ...) using RS485 What is this lib ? This lib is meant to talk to P

Frank 26 Dec 28, 2022
"3D Human Texture Estimation from a Single Image with Transformers", ICCV 2021

Texformer: 3D Human Texture Estimation from a Single Image with Transformers This is the official implementation of "3D Human Texture Estimation from

XiangyuXu 193 Dec 05, 2022
๐Ÿš€ PyTorch Implementation of "Progressive Distillation for Fast Sampling of Diffusion Models(v-diffusion)"

PyTorch Implementation of "Progressive Distillation for Fast Sampling of Diffusion Models(v-diffusion)" Unofficial PyTorch Implementation of Progressi

Vitaliy Hramchenko 58 Dec 19, 2022
ROS-UGV-Control-Interface - Control interface which can be used in any UGV

ROS-UGV-Control-Interface Cam Closed: Cam Opened:

Ahmet Fatih Akcan 1 Nov 04, 2022
Dataset and codebase for NeurIPS 2021 paper: Exploring Forensic Dental Identification with Deep Learning

Repository under construction. Example dataset, checkpoints, and training/testing scripts will be avaible soon! ๐Ÿ’ก Collated best practices from most p

4 Jun 26, 2022