/tutorials

Primary LanguageJupyter Notebook

Table of Contents

  1. README
    1. How to read this README
    2. Docker
      1. Install Docker
      2. Pull MLSS docker image
      3. Run docker image with Jupyter
      4. Removing a running docker container
    3. Conda
    4. Tutorials
      1. Deep Learning
      2. Optimization
      3. Variational Inference
      4. Reinforcement Learning
      5. Gaussian Processes
      6. Kernels
      7. Markov Chain Monte Carlo
      8. Approximate Bayesian Computation
      9. Speech Processing
      10. ML in Computational Biology
      11. Submodularity

README

MLSS 2019 will have interactive and practical tutorials in the following subjects

  • Deep Learning
  • Optimization
  • Variational Inference
  • Reinforcement Learning
  • Gaussian Processes
  • Kernels
  • Markov Chain Monte Carlo
  • Approximate Bayesian Computation
  • Speech Processing
  • ML in Computational Biology

Since many of these tutorials require the participants to install software with sometimes complex dependencies which means the installation process will differ between platforms (e.g Linux, OSX and Windows) and to make sure the tutorials run smoothly, we have prepared ways for everyone to come prepared and reduce technical issues to minimum.

This means we will get more time for the actual content!

How to read this README

Since the tutorials differ in terms of programming languages used and how the tutorials will be run, each tutorial will get its own section where instructions on how to get started and get the environment for this tutorial up and running.

Most of the tutorials will be run from a docker image that we have created. If you want to read more about docker this can be done here.

Docker

We have created a docker image that runs a jupyter notebook with kernels for the tutorials which you will be access through localhost:8888 in your browser after you follow the guide below.

Install Docker

Follow these instruction to install docker. If you follow the guide, everything should be fine. If you still have problem, please ask in the Slack general channel or ping me (@Isak Falk) anywhere on the MLSS2019 Slack :)

  1. Install docker on your platform (Community Edition (CE), not Enterprise Edition (EE))

  2. (Linux only) Add your user to the docker group by running

    sudo usermod -a -G docker $USER
    

    in a terminal. This will enable you to run docker commands without using sudo.

  3. Make sure Docker works

    • Command line / terminal: In a terminal run docker run hello-world, this will give an output similar to this
    • Application: Make sure the Docker application is installed and that you can find the icon when you search for it (this will depend on your system)

Pull MLSS docker image

Pull the MLSS docker image to your computer, this image is located here.

Run the following in a terminal

docker pull isakfalk/mlss:latest

This will make the image available to you on your system. The image is a bit large (3gb compressed, 7gb uncompressed), this is normal, don't worry about it.

Run docker image with Jupyter

In order to get jupyter working, do the following from a terminal (note: this is how I do it on Linux, let me know if we need to do it another way on another platform)

  1. Run docker run --name mlss -p 8888:8888 isakfalk/mlss, this will start the image we pulled (isakfalk/mlss), name is mlss and forward port 8888 on the image to the port 8888 on our machine.
  2. You should see the following in your terminal img Copy the outlined part (you can do this using the command ctrl-shift-c in a terminal on Linux at least)
  3. In your browser of choice, do the following: paste the copied part into the browser and prefix it with localhost, like the image below img
  4. Congratulations! It should be working now. You can change the kernel to the tutorial kernel by clicking on the notebook you want to run and then go to the tab Kernel and choose Change kernel, you will be presented with the available kernels.

Removing a running docker container

When you are done with the jupyter notebook, we need to clean up the container as else it will not exit. Do the following to stop the jupyter notebook and clean up

  1. Run docker container stop mlss
  2. Run docker container rm mlss

Conda

Some tutorials do not use jupyter notebooks. In this case, make sure you have anaconda installed on your machine. Then run the following in a terminal where $TUTORIALS_DIR is the path to the git directory of the mlss2019 tutorials that you can clone from here and $ENV_NAME.yml is the name of the environment yaml file:

cd $TUTORIALS_DIR/environments/
conda env create -f $ENV_NAME.yml
conda activate $ENV_NAME

You should now be in the conda environment and can run the necessay files (e.g. python tutorial.py) successfully.

Alternatively, this could be done from the anaconda application directly.

Tutorials

Deep Learning

Colab

Running the notebooks in colab gives you access to GPU which will be good to have. They run out of the box since the colab has all the needed libraries pre-installed.

Docker

See Docker, or go directly to how to run jupyter with docker if you have already installed and pulled the docker image.

NOTE: the docker image is getting very big. I have provided a new image which you can pull using docker pull isakfalk/mlss_dl and then follow the guide as before.

Optimization

Docker

See Docker, or go directly to how to run jupyter with docker if you have already installed and pulled the docker image.

There will be a kernel called Julia 1.1.1 which you will have to choose.

Locally

To run the Optimization notebooks, you'll need to install Julia (to run locally). An easy guide to follow can be found here. You'll need to have a recent version of Python installed (3.x), and it's easiest if this is from the Anaconda distribution. I'll assume you have this.

For Julia, you'll need to install some packages as well to run things. From a Julia terminal, execute the following code:

using Pkg
Pkg.add("Distributions");
Pkg.add("SpecialFunctions");
Pkg.add("PyPlot");

Variational Inference

Best to run this in colab as you will get access to GPU. Upload the jupyter notebook $TUTORIALS_DIR/VAE/MLSS2019_VAEs_exercise.ipynb to Google Colab and run it there.

If you want / need to run it locally, see Docker, or go directly to how to run jupyter with docker if you have already installed and pulled the docker image.

Reinforcement Learning

See Docker, or go directly to how to run jupyter with docker if you have already installed and pulled the docker image.

If you are using docker, don't run the following cells

# install required packages
!pip install --upgrade chainer opencv-python gym matplotlib==3.0.3 numpy
# uncomment to install minerl
!pip install --upgrade minerl

since the conda kernel already has these packages installed.

Gaussian Processes

See Docker, or go directly to how to run jupyter with docker if you have already installed and pulled the docker image.

  1. Lab1 - Sampling a GP.ipynb

    If you find that the first cell

    import numpy as np
    import matplotlib
    matplotlib.rcParams['figure.figsize'] = (14, 6)
    plt = matplotlib.pyplot
    

    doesn't work, change this cell to

    import numpy as np
    import matplotlib
    matplotlib.rcParams['figure.figsize'] = (14, 6)
    import matplotlib.pyplot as plt
    
  2. Lab2 - GPflow and GP Regression.ipynb

    See Lab1

Kernels

TODO

Markov Chain Monte Carlo

See Conda with $ENV_NAME.yml set to mlss_mcmc.yml. After activating the environment, go to $TUTORIALS_DIR/betancourt/ and then run each tutorial by using

python $TUTORIAL_NAME.py

Approximate Bayesian Computation

Locally

Install scipy, matplotlib and tqdm via conda/pip. Then run jupyter notebook and launch abc_filippi/ABC.ipynb.

Colab

Import abc_filippi/ABC.ipynb either from your local copy or the GitHub repository.

Speech Processing

Locally

Install simplejson and pytorch via conda/pip and editdistance and soundfile via pip. Then run jupyter notebook and launch speech/tutorial.ipynb.

Colab

Place and rename the speech folder in this repository into your personal Google Drive folder (Google Drive is needed) at MLSS2019/tutorials (note that speech needs to be renamed to tutorials). Import speech/tutorial.ipynb either from your local copy or the GitHub repository.

ML in Computational Biology

TODO

Submodularity

The tutorial is in $TUTORIALS_DIR/submodular/submodular-opt.ipynb and should work in Colab out of the box. Alternatively, you can set up Conda with $ENV_NAME.yml set to mlss_submod.yml. After activating the Conda environment, ensure jupyter can access the environment by running

python -m ipykernel install --user --name mlss_submod --display-name "Python (mlss_submod)"

Then, launch the notebook via jupyter notebook and open the tutorial.

TODO: can we add this to the docker image?