Git Product home page Git Product logo

stochastic_stein_discrepancy's Introduction

Stochastic Stein Discrepancies

This repo contains many experiments that utilize the Stochastic Stein discrepancy. The paper explaining the theory of this can be found here.

Requirements

The first two experiments are written in Julia v0.6. There is a file src/startup.jl which simply adds the paths of some modules to the LOAD_PATH variable. You should either simlink this file to ~/.juliarc.jl or add the lines from this file to your current .juliarc.jl. There is a REQUIRE file that demarcates all the necessary Julia packages needed to run all the experiments; these can be added by runnning inside a Julia repl

Pkg.add("<package_name>")

The third experiment (SSVGD) is a fork of an existing Python repo. In order to install the requirements for that experiment, please first install Miniconda and then run the following commands:

cd src/experiments/Stein-Variational-Gradient-Descent/
conda create --name svgd python=2.7
source activate svgd
pip install -r requirements.txt

This will prepare your python environment. Run

source decativate

to exit the virtual Python env.

Training

Below outlines how to run each experiment:

Experiment 1: (Hyperparameter selection for approximate MCMC)

This command should be run from the base directory of this repo. To generate the data for the first experiment, one should run

julia src/experiments/compare-hyperparameters-gmm-posterior.jl --likelihoodn=<n>

where n is 0, 1, and 10. This will dump artifacts in the results directory.

Experiment 2: Selecting biased MCMC samplers

This command should be run from the base directory of this repo. To generate the data for the first experiment, one should run

julia src/experiments/mnist_7_or_9_sgfs.jl --sampler=<sampler> --likelihoodn=<n>

where (sample, n) belongs to {SGFS-f, SGFS-d} x {0, 1000, 100}. This will dump artifacts in the results directory.

Experiment 3: Improving particle approximations with SSVGD

This is the only experiment to be run using Python2. From the base directory, run

mkdir -p results/stochastic_svgd/data/
cd src/experiments/Stein-Variational-Gradient-Descent/python

Assuming you have already activated the conda environment with

source activate svgd

then one can kick off the experiments by running

python run_experiments.py --particles=20 --n_hidden=50 --dataset=<dataset> --batch_size_frac=<b> --stepsize=<eps> --get-checkpoints > ../../../../results/stochastic_svgd/data/svgd_dataset=<dataset>_batchsizefrac=<b>_nhidden=50_particles=20_stepsize=<eps>.tsv

where b is chosen from {0.1, 0.25, 1.0} and (dataset, eps) are chosen from {(yacht, 1e-2), (boston, 1e-3), (naval, 1e-3)}. This will generate artifacts in the proper location to make visualization easier.

Evaluation

All scripts to plot the results can be found in the src/visualization directory. The version of R used was v3.4.2. These can be run via Rscript from inside the src/visualization directory, e.g.,

cd src/visualization
Rscript stochastic-checkpoint-svgd-comparison_viz.R

stochastic_stein_discrepancy's People

Contributors

jgorham avatar

Watchers

 avatar paper2code - bot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.