A Tensorflow implementation of CapsNet based on Geoffrey Hinton's paper Dynamic Routing Between Capsules
The code was derive from naturomics/CapsNet-Tensorflow . To apply to the Chinese Character Recognization competions(**古汉字识别,或者成为书法识别比赛),I made some improvements.
- The parameters of original code edition are fixed, it is troublesome to change the conv layer's kernel size. Now you can set it casual.
- To improve the accuracy of Chinese Character, I add a more conv layer ,the shape of input_image is 64*64*1
Notes:
- The current version supports **书法识别 The current test accuracy for MNIST is
93.42%
- See dist_version for multi-GPU support
- Python
- NumPy
- Tensorflow>=1.3
- tqdm (for displaying training progress info)
- scipy (for saving images)
Step 1. Download this repository with git
$ git clone [email protected]:mixianbuguoqiao/CapsNet-Character-Tensorflow.git
$ cd CapsNet-Tensorflow
Step 2. Download Chinese-Character
Manual downloading with wget
or other tools, move and extract dataset into data
for example:
$ mkdir -p data
Step 3. Start the training(Using the MNIST dataset by default):
$ python main.py
$ or python main.py --dataset character
$ # If you need to monitor the training process, open tensorboard with this command
$ tensorboard --logdir=logdir
Step 4. Calculate test accuracy
$ python main.py --is_training=False
$ # for fashion-mnist dataset
$ python main.py --dataset fashion-mnist --is_training=False
Note: The default parameters of batch size is 1, and epoch 50. You may need to modify the
config.py
file or use command line parameters to suit your case, e.g. set batch size to 32 and do once test summary every 200 steps:python main.py --test_sum_freq=100 --batch_size=32
- naturomics/CapsNet-Tensorflow: referred for some code optimizations