According to leifeng AI Institute, we still remember the capsule network published by “godfather of deep learning” Geoffery Hinton at the end of last year. In Dynamic Routing Between Capsules, Hinton’s team came up with an entirely new network architecture. To avoid clutter, they propose to bundle neurons that focus on the same category or property together, like capsules. When the neural network works, the pathways between these capsules form a sparsely activated tree structure (only part of the pathways in the whole tree are activated). As a result, Capsule is more explanatory.

In the experimental results, CapsNet has achieved good results in number recognition and robustness. For more, see Hinton’s new Capsule paper. Could it usher in a new era of deep neural networks?

Sara Sabour, lead author of the paper, posted the code on GitHub today so you can get your hands dirty. Lei Feng net AI Institute will compile the tutorial as follows:

Required configurations:

  • TensorFlow(click www.tensorflow.org to install or upgrade)

  • NumPy (www.numpy.org/)

  • GPU

Verify that the installation is correct by executing the test program, such as:

python layers_test.py

Rapid MNIST test:

  • Download and extract MNIST TFRecord to $DATA_DIR/ :

    Storage.googleapis.com/capsule_tor…

  • $CKPT_DIR: $CKPT_DIR:

    Storage.googleapis.com/capsule_tor…

python experiment.py –data_dir=$DATA_DIR/mnist_data/ –train=false \

–summary_dir=/tmp/ –checkpoint=$CKPT_DIR/mnist_checkpoint/model.ckpt-1

Fast CIFAR10 Ensemble Test:

  • Download and extract the ciFAR10 binary file to $DATA_DIR/ :

    www.cs.toronto.edu/~kriz/cifar…

  • $CKPT_DIR = $CKPT_DIR

    Storage.googleapis.com/capsule_tor…

  • Pass the directory ($DATA_DIR) as DATA_DIR:

python experiment.py –data_dir=$DATA_DIR –train=false –dataset=cifar10 \

–hparams_override=num_prime_capsules=64,padding=SAME,leaky=true,remake=false \

–summary_dir=/tmp/ –checkpoint=$CKPT_DIR/cifar/cifar{}/model.ckpt-600000 \

–num_trials=7

CIFAR10 Training instructions:

python experiment.py –data_dir=$DATA_DIR –dataset=cifar10 –max_steps=600000\

–hparams_override=num_prime_capsules=64,padding=SAME,leaky=true,remake=false \

–summary_dir=/tmp/

MNIST full training instruction:

  • You can also run –validate=true as well to train on train-test sets

  • Execute –num_gpus= num_gpus to train on multiple Gpus

python experiment.py –data_dir=$DATA_DIR/mnist_data/ –max_steps=300000\

–summary_dir=/tmp/attempt0/

MNIST Baseline Training Instruction:

python experiment.py –data_dir=$DATA_DIR/mnist_data/ –max_steps=300000\

–summary_dir=/tmp/attempt1/ –model=baseline

To test on validation during training of the above model:

When training the above model, test on the validation set (remember that instructions are continuously executed during training) :

  • Execute –validate=true during training as well

  • You might need two Gpus, one for the training set and one for the validation set

  • If all the tests are on a single machine, you need to limit RAM consumption in tests for training sets and validation sets. Otherwise, TensorFlow will take up all the RAM in the first place, and no other work can be done

python experiment.py –data_dir=$DATA_DIR/mnist_data/ –max_steps=300000\

–summary_dir=/tmp/attempt0/ –train=false –validate=true

MultiMNIST is available for testing or training with –num_targets=2 and — data_DIR =$data_DIR /multitest_6shifted_mnist.tfrecords@10 The code for generating multiMNIST/MNIST records is in the directory input_data/ MNIST/ mnist_shift.py.

MultiMNIST test code:

python mnist_shift.py –data_dir=$DATA_DIR/mnist_data/ –split=test –shift=6

–pad=4 –num_pairs=1000 –max_shard=100000 –multi_targets=true

AffNIST expanded_mnist can be constructed with –shift=6 –pad=6

Address: arxiv.org/pdf/1710.09…

GitHub address: github.com/Sarasra/mod…

Lei Feng net (public number: Lei Feng net) AI Institute compiled and collated.

(after)