PyTorch and GPyTorch implementation of the paper "Conditioning Sparse Variational Gaussian Processes for Online Decision-making."

Overview

Conditioning Sparse Variational Gaussian Processes for Online Decision-making

This repository contains a PyTorch and GPyTorch implementation of the paper "Conditioning Sparse Variational Gaussian Processes for Online Decision-making."

Introduction

Online variational conditioning (OVC) provides closed form conditioning (e.g. updating a model's posterior predictive distribution after having observed new data points) for stochastic variational Gaussian processes. OVC enables the development of ``fantasization" (predicting on data and then conditioning on a random posterior sample) for variational GPs, thereby enabling SVGPs to be used for the first time in advanced, look-ahead acquisitions such as the batch knowledge gradient, entropy search, and look-ahead Thompson sampling (which we introduce).

In this repo, we provide an implementation of a SVGP model with OVC hooked up as the get_fantasy_model function, allowing it to be natively used with any advanced acquisition function in BoTorch (see the experiments in the experiments/std_bayesopt folder).

Installation

python setup.py develop

See requirements.txt for our setup. We require Pytorch >= 1.8.0 and used the master versions of GPyTorch and BoTorch installed from source.

File Structure

.
+-- volatilitygp/
|   +-- likelihoods/
|   |   +-- _one_dimensional_likelihood.py (Implementation of Newton iteration and the base class for the others)
|   |   +-- bernoulli_likelihood.py
|   |   +-- binomial_likelihood.py
|   |   +-- fixed_noise_gaussian_likelihood.py
|   |   +-- multivariate_normal_likelihood.py
|   |   +-- poisson_likelihood.py
|   |   +-- volatility_likelihood.py
|   +-- mlls/
|   |   +-- patched_variational_elbo.py (patched version of elbo to allow sumMLL training)
|   +-- models/
|   |   +-- model_list_gp.py (patched version of ModelListGP to allow for SVGP models)
|   |   +-- single_task_variational_gp.py (Our basic model class for SVGPs)
|   +-- utils/
|   |   +-- pivoted_cholesky.py (our pivoted cholesky implementation for inducing point init)
+-- experiments/
|   +-- active_learning/ (malaria experiment)
|   |   +-- qnIPV_experiment.py (main script)
|   +-- highd_bo/ (rover experiments)
|   |   +-- run_trbo.py (turbo script)
|   |   +-- run_gibbon.py (global model script, Fig 10c)
|   |   +-- rover_conditioning_experiment.ipynb (Fig 10b)
|   |   +-- trbo.py (turbo implementation)
|   +-- hotspots/ (schistomiasis experiment)
|   |   +-- hotspots.py (main script)
|   +-- mujoco/ (mujoco experiments on swimmer and hopper)
|   |   +-- functions/ (mujoco functions)
|   |   +-- lamcts/ (LA-MCTS implementation)
|   |   +-- turbo_1/ (TurBO implementation)
|   |   run.py (main script)
|   +-- pref_learning/ (preference learning experiment)
|   |   +-- run_pref_learning_exp.py (main script)
|   +-- std_bayesopt/ (bayes opt experiments)
|   |   +-- hartmann6.py (constrained hartmann6)
|   |   +-- lcls_optimization.py (laser)
|   |   +-- poisson_hartmann6.py (poisson constrained hartmann6)
|   |   +-- utils.py (model definition helpers)
|   |   +-- weighted_gp_benchmark/ (python 3 version of WOGP)
|   |   |   +-- lcls_opt_script.py (main script)
+-- tests/ (assorted unit tests for the volatilitygp package)

Commands

Please see each experiment folder for the larger scale experiments.

The understanding experiments can be found in:

  • Figure 1a-b: notebooks/svgp_fantasization_plotting.ipynb
  • Figure 1c: notebooks/SABR_vol_plotting.ipynb
  • Figure 2b-d: experiments/std_bayesopt/knowledge_gradient_branin_plotting.ipynb
  • Figure 6: notebooks/ssgp_port.ipynb
  • Figure 7: notebooks/ssgp_time_series_testing_pivcholesky.ipynb
  • Figure 8: notebooks/streaming_bananas_plots.ipynb
  • Figure 10b: experiments/highd_bo/rover_conditioning_experiment.ipynb

Code Credits and References

  • BoTorch (https://botorch.org). Throughout, many examples were inspired by assorted BoTorch tutorials, while we directly compare to Botorch single task GPs.
  • GPyTorch (https://gpytorch.ai). Our implementation of SVGPs rests on this implementation.
  • LA-MCTS code comes from here
  • laser WOGP code comes from here
  • hotspots data comes from here
  • malaria active learning script comes from here. Data can be downloaded from here.
You might also like...
Implementation of EMNLP 2017 Paper
Implementation of EMNLP 2017 Paper "Natural Language Does Not Emerge 'Naturally' in Multi-Agent Dialog" using PyTorch and ParlAI

Language Emergence in Multi Agent Dialog Code for the Paper Natural Language Does Not Emerge 'Naturally' in Multi-Agent Dialog Satwik Kottur, José M.

Unofficial pytorch implementation of the paper "Dynamic High-Pass Filtering and Multi-Spectral Attention for Image Super-Resolution"

DFSA Unofficial pytorch implementation of the ICCV 2021 paper "Dynamic High-Pass Filtering and Multi-Spectral Attention for Image Super-Resolution" (p

PyTorch implementation of the method described in the paper VoiceLoop: Voice Fitting and Synthesis via a Phonological Loop.
PyTorch implementation of the method described in the paper VoiceLoop: Voice Fitting and Synthesis via a Phonological Loop.

VoiceLoop PyTorch implementation of the method described in the paper VoiceLoop: Voice Fitting and Synthesis via a Phonological Loop. VoiceLoop is a n

Pytorch implementation of the paper "Enhancing Content Preservation in Text Style Transfer Using Reverse Attention and Conditional Layer Normalization"

Pytorch implementation of the paper "Enhancing Content Preservation in Text Style Transfer Using Reverse Attention and Conditional Layer Normalization"

[CVPR 2022] Pytorch implementation of
[CVPR 2022] Pytorch implementation of "Templates for 3D Object Pose Estimation Revisited: Generalization to New objects and Robustness to Occlusions" paper

template-pose Pytorch implementation of "Templates for 3D Object Pose Estimation Revisited: Generalization to New objects and Robustness to Occlusions

Pytorch re-implementation of Paper: SwinTextSpotter: Scene Text Spotting via Better Synergy between Text Detection and Text Recognition (CVPR 2022)
Pytorch re-implementation of Paper: SwinTextSpotter: Scene Text Spotting via Better Synergy between Text Detection and Text Recognition (CVPR 2022)

SwinTextSpotter This is the pytorch implementation of Paper: SwinTextSpotter: Scene Text Spotting via Better Synergy between Text Detection and Text R

RetinaNet-PyTorch - A RetinaNet Pytorch Implementation on remote sensing images and has the similar mAP result with RetinaNet in MMdetection Official PyTorch implementation for paper Context Matters: Graph-based Self-supervised Representation Learning for Medical Images
Official PyTorch implementation for paper Context Matters: Graph-based Self-supervised Representation Learning for Medical Images

Context Matters: Graph-based Self-supervised Representation Learning for Medical Images Official PyTorch implementation for paper Context Matters: Gra

A PyTorch re-implementation of the paper 'Exploring Simple Siamese Representation Learning'. Reproduced the 67.8% Top1 Acc on ImageNet.

Exploring simple siamese representation learning This is a PyTorch re-implementation of the SimSiam paper on ImageNet dataset. The results match that

Comments
  • fixing wishart import error; file missing and not required

    fixing wishart import error; file missing and not required

    __init__.py in likelihoods has an import for wishart_likelihood.py which is missing because of which experiments can't run and exit with an error. It is not used anywhere so just deleted the import.

    opened by prakharverma 1
  • Cannot reproduce `active_learning` experiment

    Cannot reproduce `active_learning` experiment

    When running

    python qnIPV_experiment.py --num_init=10 --model=svgp --num_steps=250 --seed=1 --output=malaria_nipv_svgp_1.pt
    

    as given in the README.md, I get the following exception:

    Traceback (most recent call last):
      File "qnIPV_experiment.py", line 301, in <module>
        main(args)
      File "qnIPV_experiment.py", line 228, in main
        candidates, acq_value = optimize_acqf(
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/optim/optimize.py", line 150, in optimize_acqf
        batch_initial_conditions = ic_gen(
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/optim/initializers.py", line 112, in gen_batch_initial_conditions
        Y_rnd_curr = acq_function(
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
        return forward_call(*input, **kwargs)
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/utils/transforms.py", line 255, in decorated
        return method(cls, X, **kwargs)
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/utils/transforms.py", line 214, in decorated
        output = method(acqf, X, *args, **kwargs)
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/acquisition/active_learning.py", line 92, in forward
        fantasy_model = self.model.fantasize(
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/models/model.py", line 140, in fantasize
        return self.condition_on_observations(X=X, Y=Y_fantasized, **kwargs)
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/models/gpytorch.py", line 196, in condition_on_observations
        return self.get_fantasy_model(inputs=X, targets=Y, **kwargs)
      File ".../online_vargp/volatilitygp/models/single_task_variational_gp.py", line 513, in get_fantasy_model
        return super().get_fantasy_model(
      File ".../online_vargp/volatilitygp/models/single_task_variational_gp.py", line 361, in get_fantasy_model
        fantasy_model = inducing_exact_model.condition_on_observations(
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/models/gpytorch.py", line 394, in condition_on_observations
        self._validate_tensor_args(X=X, Y=Y, Yvar=noise, strict=False)
      File ".../anaconda3/envs/onlinet/lib/python3.8/site-packages/botorch/models/gpytorch.py", line 94, in _validate_tensor_args
        raise BotorchTensorDimensionError(
    botorch.exceptions.errors.BotorchTensorDimensionError: An explicit output dimension is required for observation noise. Expected Yvar with shape: torch.Size([6, 1]) (got torch.Size([5, 6])).
    

    Calling the experiment script with --random, or running --model=exact (with or without --random) runs fine.

    Might this have something to do with the svgp model getting init_y.view(-1) whereas the other models get init_y.view(-1, 1) (similarly for init_y_var)?

    opened by st-- 6
Owner
Wesley Maddox
PhD student at New York University.
Wesley Maddox
The LaTeX and Python code for generating the paper, experiments' results and visualizations reported in each paper is available (whenever possible) in the paper's directory

This repository contains the software implementation of most algorithms used or developed in my research. The LaTeX and Python code for generating the

João Fonseca 3 Jan 3, 2023
ALBERT-pytorch-implementation - ALBERT pytorch implementation

ALBERT-pytorch-implementation developing... 모델의 개념이해를 돕기 위한 구현물로 현재 변수명을 상세히 적었고

BG Kim 3 Oct 6, 2022
PyTorch implementation of CVPR 2020 paper (Reference-Based Sketch Image Colorization using Augmented-Self Reference and Dense Semantic Correspondence) and pre-trained model on ImageNet dataset

Reference-Based-Sketch-Image-Colorization-ImageNet This is a PyTorch implementation of CVPR 2020 paper (Reference-Based Sketch Image Colorization usin

Yuzhi ZHAO 11 Jul 28, 2022
The official PyTorch implementation of recent paper - SAINT: Improved Neural Networks for Tabular Data via Row Attention and Contrastive Pre-Training

This repository is the official PyTorch implementation of SAINT. Find the paper on arxiv SAINT: Improved Neural Networks for Tabular Data via Row Atte

Gowthami Somepalli 284 Dec 21, 2022
Official PyTorch implementation and pretrained models of the paper Self-Supervised Classification Network

Self-Classifier: Self-Supervised Classification Network Official PyTorch implementation and pretrained models of the paper Self-Supervised Classificat

Elad Amrani 24 Dec 21, 2022
Implementation of EMNLP 2017 Paper "Natural Language Does Not Emerge 'Naturally' in Multi-Agent Dialog" using PyTorch and ParlAI

Language Emergence in Multi Agent Dialog Code for the Paper Natural Language Does Not Emerge 'Naturally' in Multi-Agent Dialog Satwik Kottur, José M.

Karan Desai 105 Nov 25, 2022
A pytorch implementation of the ACL2019 paper "Simple and Effective Text Matching with Richer Alignment Features".

RE2 This is a pytorch implementation of the ACL 2019 paper "Simple and Effective Text Matching with Richer Alignment Features". The original Tensorflo

null 287 Dec 21, 2022
Pytorch implementation of CVPR2020 paper “VectorNet: Encoding HD Maps and Agent Dynamics from Vectorized Representation”

VectorNet Re-implementation This is the unofficial pytorch implementation of CVPR2020 paper "VectorNet: Encoding HD Maps and Agent Dynamics from Vecto

null 120 Jan 6, 2023
Unofficial PyTorch implementation of MobileViT based on paper "MobileViT: Light-weight, General-purpose, and Mobile-friendly Vision Transformer".

MobileViT RegNet Unofficial PyTorch implementation of MobileViT based on paper MOBILEVIT: LIGHT-WEIGHT, GENERAL-PURPOSE, AND MOBILE-FRIENDLY VISION TR

Hong-Jia Chen 91 Dec 2, 2022
Pytorch implementation of paper "Learning Co-segmentation by Segment Swapping for Retrieval and Discovery"

SegSwap Pytorch implementation of paper "Learning Co-segmentation by Segment Swapping for Retrieval and Discovery" [PDF] [Project page] If our project

xshen 41 Dec 10, 2022