Code Monkey home page Code Monkey logo

capsnet-fashion-mnist's Introduction

CapsNet-Fashion-MNIST

License

A Keras implementation of CapsNet in the paper:
Sara Sabour, Nicholas Frosst, Geoffrey E Hinton. Dynamic Routing Between Capsules. NIPS 2017

This code is adopted from CapsNet-Keras to test the performance of CapsNet on Fashion-MNIST

Contacts
Xifeng Guo
E-mail [email protected] or WeChat wenlong-guo.

Usage

Step 1. Install Keras 2.0.9 with TensorFlow backend.

pip install tensorflow-gpu
pip install keras==2.0.9

Step 2. Clone this repository to local.

git clone https://github.com/XifengGuo/CapsNet-Fashion-MNIST.git
cd CapsNet-Fashion-MNIST

Step 3. Train a CapsNet on Fashion-MNIST

Training with default settings:

$ python capsulenet.py

Data preprocessing:

  • scale pixel values to [0,1];
  • shift 2 pixels and horizontal flipping augmentation.

Results

Accuracy

Test Accuracy: 93.62%

Losses and accuracies:

Training Speed

About 120s / epoch on a single GTX 1070 GPU.

Reconstruction result

Top 5 rows are real images from MNIST and Bottom are corresponding reconstructed images.

capsnet-fashion-mnist's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

capsnet-fashion-mnist's Issues

reconstruction error for RGB images

I'm running capsnet with 28*28 RGB cell images. I'm able to achieve good accuracy however, I've issues with reconstructing the test data, due to dimension mismatch. Could you please assist me in modifying the definition for test to suit RGB images? Here is the code:

def test(model, data, args):
#    x_test, y_test = data
    y_pred, x_recon = model.predict([x_test, y_test], batch_size=100)
    print('Test acc:', np.sum(np.argmax(y_pred, 1) == np.argmax(y_test, 1))/y_test.shape[0])
    image = combine_images(np.concatenate([x_test[:50],x_recon[:50]]))
    image = image * 255
    Image.fromarray(image.astype(np.uint8)).save(args.save_dir + "/real_and_recon.png")
    print()
    print('Reconstructed images are saved to %s/real_and_recon.png' % args.save_dir)
    plt.imshow(plt.imread(args.save_dir + "/real_and_recon.png"))
    plt.show()

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.