Giter Site home page Giter Site logo

capsule-networks's Introduction

Capsule Networks

A Tensorflow implementation of Capsule Networks

For more information on Capsule Networks please read my Medium article.

[Update] Check out my new article with a deeper explanation on how capsules work.

This repo was largely based off of naturomics CapsNet-Tensorflow repo with the current differences being an added requirements.txt and the MNIST dataset is included. Power users may want to refer to the naturomics repo for the latest versions.

Usage

Install the requirements and download dataset:

pip install -r requirements.txt
python download_data.py

Start training!

python main.py

Testing Accuracy

python main.py --is_training False

Visualization

Check out this Visualization Tool I built to play around with the DigitCaps vectors to see how it effects the recontructions:

capsule-networks's People

Contributors

bourdakos1 avatar

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  avatar  avatar

Watchers

 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

capsule-networks's Issues

Why the dimensions of weights are dependent on batch_size?

In ANN and CNN, the weights are not dependent on batch_size. But here (wij and bij) it is tiled according to batch_size and that number of weights will be trained.

What if we want to input a single image and get its classification. The whole model needs to be reconstructed and retrained for that batch_size=1?

The usage of GPU is lower than 50% when training process.

@bourdakos1 Hi!
The usage of GPU is lower than 50% when training process.
when i run this: python main.py, the progress is working well, but the usage of GPU is lower than 50%. How to improve the usage of GPU to save time?

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 415.27 Driver Version: 415.27 CUDA Version: 10.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce RTX 2070 Off | 00000000:01:00.0 On | N/A |
| 40% 52C P2 71W / 185W | 5225MiB / 7949MiB | 33% Default |
+-------------------------------+----------------------+----------------------+

tensorflow-gpu not working.

I have installed tensorflow-gpu on my desktop which has two high powered NVidia gpu cards and it unfortunately is not using the gpu. I have implicitly told it to import tensorflow-gpu and it causes an error. Does anyone know how to get the main.py code to use the GPU?

How to use it for another dataset

Hey, i am having problem intergrating this with another dataset
it includes folders as label and different images in it.

Class1/
image1.jpg
image2.jpg

Class2/
image1.jpg
image2.jpg

.
.
.

Can you help me with this issue?

import pb with config

from capsule.config import cfg
from capsule.utils import load_mnist
from capsule.capsNet import CapsNet

import os
import tensorflow as tf
from tqdm import tqdm

return :
ModuleNotFoundError Traceback (most recent call last)
/content/capsule/capsNet.py in ()
7 import tensorflow as tf
8
----> 9 from config import cfg
10 from utils import get_batch_data
11 from capsLayer import CapsLayer

ModuleNotFoundError: No module named 'config'

Cublas handle error

Hi,
I am getting an error when trying to run your code: "failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED". I've used the GPU before, so I am not sure why I am getting this error.

My configuration : Win 10, NVIDIA GeForce 1070, CUDA 9.1, cudnn 7.0.5. I onlt have 1 GPU, so I changed your config file to only train on one gpu (flags.DEFINE_integer('num_gpu', 1, 'number of gpus for distributed training'))

Suggestions for README

Excellent Hacker-Noon article. Dramatic and informative! Congrats...
However, more credit (which you partially do!) should be given to the CapsNet-Tensorflow repro by Huadong Liao (aka Naturomics). His README is helpful.
Question: How does the Naturomics and your repro differ from Hinton's repro? So, it uses both Keras and TF. Why did you not use the Naturomics repro? Should mention this issue in your README.
In any case, excellent article that help me understand the significance behind capsule networks. Upgrade your README, inserting a link to your article and copying a few paragraphs at the end about how-to-use.

Capsnet() error

Hi,

Thank you for your job.

I would use it, when a try to initialise capsNet() i found this error. Can you help me?

capsNet = CapsNet(is_training=cfg.is_training)

UnrecognizedFlagErrorTraceback (most recent call last)
<ipython-input-4-894105a67f23> in <module>()
----> 1 capsNet = CapsNet(is_training=cfg.is_training)

/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/flags.pyc in __getattr__(self, name)
     82     # a flag.
     83     if not wrapped.is_parsed():
---> 84       wrapped(_sys.argv)
     85     return wrapped.__getattr__(name)
     86 

/usr/local/lib/python2.7/dist-packages/absl/flags/_flagvalues.pyc in __call__(self, argv, known_only)
    630       suggestions = _helpers.get_flag_suggestions(name, list(self))
    631       raise _exceptions.UnrecognizedFlagError(
--> 632           name, value, suggestions=suggestions)
    633 
    634     self.mark_as_parsed()

UnrecognizedFlagError: Unknown command line flag 'f'

Thank you

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.