胶囊模型的代码在Windows下的测试,99.76%正确率

胶囊模型的代码在Windows下的测试,99.76%正确率


当前的深度学习理论是由Geoffrey Hinton大神在2007年确立起来的,但是如今他却认为,“CNN的特征提取层与次抽样层交叉存取,将相同类型的相邻特征检测器的输出汇集到一起”是大有问题的。
去年9月,在多伦多接受媒体采访时,Hinton大神断然宣称要放弃反向传播,让整个人工智能从头再造。10月,人们关注已久的Hinton大神那篇Capsule论文”Dynamic Routing between Capsules”终于揭开面纱。
在论文中,Capsule被Hinton大神定义为这样一组神经元:其活动向量所表示的是特定实体类型的实例化参数。他的实验表明,鉴别式训练的多层Capsule系统,在MNIST手写数据集上表现出目前最先进的性能,并且在识别高度重叠数字的效果要远好于CNN。


近日,该论文的一作Sara Sabour终于在GitHub上公开了该论文中的代码。该项目上线5天便获得了217个Star,并被fork了14218次。下面让我们一起来看看Sara Sabour开源的代码吧。


胶囊模型的代码在以下论文中使用:

“Dynamic Routing between Capsules” by Sara Sabour, Nickolas Frosst, Geoffrey E. Hinton.
测试要求
TensorFlow ( 访问 http://www.tensorflow.org 了解如何安装和升级)
NumPy (详见http://www.numpy.org/)
GPU
可以从这里下载windows代码:
http://download.csdn.net/download/caimouse/10236791


下载实验数据和已经训练好的模型:

Quick MNIST test results:

Download and extract MNIST tfrecords to $DATA_DIR/ from: https://storage.googleapis.com/capsule_toronto/mnist_data.tar.gz

Download and extract MNIST model checkpoint to $CKPT_DIR from: https://storage.googleapis.com/capsule_toronto/mnist_checkpoints.tar.gz


github源码连接:
https://github.com/Sarasra/models/tree/master/research/capsules




windows下的训练命令行:
D:\AI\capsules\models\research\capsules> python experiment.py --data_dir=./mnist_data/ --max_steps=300000 --summary_dir=./tmp/attempt1/ --model=baseline
WARNING:tensorflow:From experiment.py:327: print_model_analysis (from tensorflow.contrib.tfprof.model_analyzer) is deprecated and will be removed after 2018-01-01.
Instructions for updating:
Use `tf.profiler.profile(graph, run_meta, op_log, cmd, options)`. Build `options` with `tf.profiler.ProfileOptionBuilder`. See README.md for details
C:\Users\tony\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\ops\nn_ops.py:1790: RuntimeWarning: overflow encountered in long_scalars
  filter_width * 2))
Parsing Inputs...


=========================Options=============================
-max_depth                  10000
-min_bytes                  0
-min_micros                 0
-min_params                 0
-min_float_ops              0
-min_occurrence             0
-step                       -1
-order_by                   name
-account_type_regexes       _trainable_variables
-start_name_regexes         .*
-trim_name_regexes
-show_name_regexes          .*
-hide_name_regexes
-account_displayed_op_only  true
-select                     params
-output                     stdout:


==================Model Analysis Report======================
node name | # parameters
_TFProfRoot (--/7.50m params)
  conv1 (--/13.31k params)
    conv1/biases (512, 512/512 params)
    conv1/weights (5x5x1x512, 12.80k/12.80k params)
  conv2 (--/3.28m params)
    conv2/biases (256, 256/256 params)
    conv2/weights (5x5x512x256, 3.28m/3.28m params)
  fc1 (--/4.20m params)
    fc1/biases (1024, 1.02k/1.02k params)
    fc1/weights (4096x1024, 4.19m/4.19m params)
  softmax_layer (--/10.25k params)
    softmax_layer/biases (10, 10/10 params)
    softmax_layer/weights (1024x10, 10.24k/10.24k params)


======================End of Report==========================


测试结果:
D:\AI\capsules\models\research\capsules> python experiment.py --data_dir=./mnist_data/ --train=false --summary_dir=./tmp/ --checkpoint=./mnist_checkpoint/model.ckpt-1
start evaluation, model defined
2018-02-02 12:33:11.369075: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2018-02-02 12:33:11.370660: W C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-02-02 12:33:11.653063: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:955] Found device 0 with properties:
name: GeForce GTX 1060 6GB
major: 6 minor: 1 memoryClockRate (GHz) 1.7845
pciBusID 0000:01:00.0
Total memory: 6.00GiB
Free memory: 4.99GiB
2018-02-02 12:33:11.653268: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:976] DMA: 0
2018-02-02 12:33:11.654043: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:986] 0:   Y
2018-02-02 12:33:11.655146: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\36\tensorflow\core\common_runtime\gpu\gpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 1060 6GB, pci bus id: 0000:01:00.0)
model loaded successfully
Total wrong predictions: 24.0, wrong percent: 0.24%

这个错误率是非常低: 0.24%,换句话说就是正确率为99.76%, 我的天啊。。。。。。。。。。。。。。。。

代码在python3.6里出错几个:

  File "D:\AI\capsules\models\research\capsules\models\capsule_model.py", line 141, in _remake
    for i in xrange(features['num_targets']):
NameError: name 'xrange' is not defined

记得把xrange改为range即可。

http://edu.csdn.net/course/detail/4810

TensorFlow API攻略
http://edu.csdn.net/course/detail/4495
TensorFlow入门基本教程
http://edu.csdn.net/course/detail/4369
C++标准模板库从入门到精通 

比特币源码入门教程

https://edu.csdn.net/course/detail/6998

深入浅出Matplotlib
https://edu.csdn.net/course/detail/6859

深入浅出Numpy
http://edu.csdn.net/course/detail/6149 

Python游戏开发入门


  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

caimouse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值