Skip to content

Instantly share code, notes, and snippets.

@jimmyahacker
Last active May 1, 2023 20:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimmyahacker/b487d64e58664358f9b2af5aa8e71ad0 to your computer and use it in GitHub Desktop.
Save jimmyahacker/b487d64e58664358f9b2af5aa8e71ad0 to your computer and use it in GitHub Desktop.
Install and run original GAN using pylearn2 on cuda backend

Prerequisites

  1. Use python2 not python3
  2. Suppose the current working directory is $CWD
  3. Suppose the data path is $DATA_PATH
  4. Suppose the current shell is bash
  5. Download following requirements.txt to current working directory
  6. Old version of cuda installed(tested on v8.0.44)
  7. Old version of cudnn installed(tested on 7.0v4.0)

Install pylearn2

  1. Install dependencies
    pip2 install -qr requirements.txt
  2. Clone pylearn2 repo to current working directory
    git clone git://github.com/lisa-lab/pylearn2.git $CWD/pylearn2
  3. Change directory
    cd $CWD/pylearn2
  4. Install pylearn2
    python2 setup.py develop
  5. Run following code to see if pylearn2 is installed correctly
    python2 -c "import pylearn2"

Get dataset

  1. Set your data path here
    echo export PYLEARN2_DATA_PATH=$DATA_PATH >> ~/.bashrc
  2. Reload bash profile
    source ~/.bashrc
  3. Download possible dataset, using mnist here for example
    python2 $CWD/pylearn2/pylearn2/scripts/datasets/download_mnist.py

Download original GAN implemented by Goodfellow

  1. Clone GAN repo to current working directory
    git clone git@github.com:goodfeli/adversarial.git $CWD/adversarial
  2. Export adversarial directory to $PYTHONPATH system variable,
    echo export PYTHONPATH=$PYTHONPATH:$CWD/adversarial >> ~/.bashrc
  3. Reload bash profile
    source ~/.bashrc
  4. Check if the system variable $PYTHONPATH is set correctly
    python2 -c "import adversarial"

Train and test model

  1. Train model and the model should be saved in $CWD/adversarial/mnist.pkl
    THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python2 -m pylearn2.scripts.train $CWD/adversarial/mnist.yaml
  2. Test model
    THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python2 -m adversarial.parzen_ll -p $CWD/adversarial/mnist.pkl -d mnist -v -s 0.01
cycler==0.10.0
Cython==0.28.3
kiwisolver==1.0.1
Mako==1.0.7
MarkupSafe==1.0
matplotlib==2.2.2
nose==1.3.7
numpy==1.14.3
pyparsing==2.2.0
python-dateutil==2.7.3
pytz==2018.4
PyYAML==3.12
scikit-learn==0.19.1
scipy==1.1.0
six==1.11.0
sklearn==0.0
subprocess32==3.5.1
Theano==0.8.0
milk==0.6.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment