GithubHelp home page GithubHelp logo

add2seconds / matrix-capsules-em-pytorch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yl-1993/matrix-capsules-em-pytorch

0.0 0.0 0.0 73 KB

A PyTorch Implementation of Matrix Capsules with EM Routing

License: MIT License

Python 100.00%

matrix-capsules-em-pytorch's Introduction

Matrix Capsules with EM Routing

A PyTorch implementation of Matrix Capsules with EM Routing

Usage

  1. Install PyTorch

  2. Start training (default: MNIST)

python train.py

Note that master is upgraded to be compatiable with PyTorch 0.4.0. If you want to use the old version of PyTorch, please

git checkout 0.3.1.post3

MNIST experiments

The experiments are conducted on TitanXP. Specific setting is lr=0.01, batch_size=128, weight_decay=0, Adam optimizer, without data augmentation. The paper does not mention the specific scheduler for inverse_temperature, it is fixed to 0.001 in our setting. As our experiments shown, \lambda between 1e-2 and 1e-4 achieves similar results. A large lambda may prevent the model from convergence.

Following is the result after 30 epochs training:

Arch Iters Coord Add Loss BN Test Accuracy
A=64, B=8, C=D=16 1 Y Spread Y 97.1
A=64, B=8, C=D=16 2 Y Spread Y 99.1
A=64, B=8, C=D=16 3 Y Spread Y 97.5
A=64, B=8, C=D=16 2 N Spread Y 99.0
A=64, B=8, C=D=16 2 Y Spread N 98.9
A=64, B=8, C=D=16 2 Y Cross-Ent Y 97.8
A=B=C=D=32 2 Y Spread Y 99.3

The training time of A=64, B=8, C=D=16 for a 128 batch is around 1.05s. The training time of A=B=C=D=32 for a 32 batch is around 1.45s.

smallNORB experiments

python train.py --dataset smallNORB --batch-size 32 --test-batch-size 256

As the paper suggests, the image is resized to 48x48, followed by randomly cropping a 32x32 patch and randomly changing brightness and contrast. Since BN is used after first normal conv layer, we do not normalize the input.

Following is the result after 50 epochs training:

Arch Iters Coord Add Loss BN Test Accuracy
A=64, B=8, C=D=16 1 Y Spread Y 74.81
A=64, B=8, C=D=16 2 Y Spread Y 89.52
A=64, B=8, C=D=16 3 Y Spread Y 82.55
A=B=C=D=32 2 Y Spread Y 90.03

A weird thing is that large batch size seems to result in poor result.

Reference

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.