Giter Site home page Giter Site logo

capsnet's Introduction

Are capsule networks really better than convolutional networks with max pooling?

Geoffrey Hinton claims that CNNs with max pooling are wrong, while capsule networks are very promising.

In paper they train capsule network to classify highly overlapping MNIST digits and get pretty impressive results.

There also is a mention (both in paper and in talks) that due to grabbing the manifold behind raw pixels capsule networks will need less data to train. This is the assumption tested here

Boring details about this implementation of CapsNet

It is based on original paper, but with few differences:

  • It is scaled down to have ~1 M params (original net has ~7M params) to have same number of params as reference CNN
  • As far as we are not interested in detecting several digits on same image, offered "margin loss" is replaced with default cross-entropy loss
  • Reconstruction loss and reconstruction sub-network are removed altogether - looks like it does not provide any performance boost
  • "Reduce learning rate on plateau" and "early stopping" tricks are applied instead of just using fixed number of epochs and TF Adam with default params

Kudos to @ageron and his TensorFlow CapsNet implementation, as well as videotutorial

Results

So here is the comparison of CapsNet vs straightforward CNN, both having ~1M parameters. Testing done on MNIST dataset

Inference time is not shown, but it is constant for both models, 50x more for CapsNet than for CNN

My reading of this data is as following:

  • If you have very small dataset (up to 3 cases per class for MNIST, probably more in more complex settings) you indeed can get decent performance edge over CNN by using CapsNet
  • This will cost you ~10X slower training and ~50x slower inference
  • With dataset growth CapsNet advantage evaporates and CNN even starts performing better (while keeping performance superiority)

DIY

So is Geoffrey Hinton really wrong and some nameless guy from GitHub right? Maybe not.

You are welcome to hack things around and hopefully improve my CapsNet implementation.

You are doubly welcome to let me know if you succeed.

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.