BWN-XNOR-caffe-master训练二进制cifar数据集
来源:互联网 发布:edg淘宝官方旗舰店 编辑:程序博客网 时间:2024/05/29 13:45
BWN-XNOR-caffe-master安装还有一些注意事项在上一个博客
目的:为了提高卷积过程的速度,和把caffe移植到FPGA上
cd BWN-XNOR-caffe-master
./data/cifar10/get_cifar10.sh #该脚本会下载二进制的cifar,并解压,会在/data/cifar10中出现很多batch文件 ./examples/cifar10/create_cifar10.sh #运行后将会在examples中出现数据集./cifar10_xxx_lmdb和数据集图像均值./mean.binaryprot
修改examples/cifar10/train_nobias.sh
#!/usr/bin/env shTOOLS=./build/toolsGLOG_log_dir=examples/cifar10/log $TOOLS/caffe train \ --solver=examples/cifar10/cifar10_full.nobias.solver $@
就是把– gpu $1 给删了
或者你在cifar10_full.nobias.solver文件中把最后两行的
solver_mode: GPUdevice_id: 3改为solver_mode: GPUdevice_id: 1或者solver_mode: CPUdevice_id: 0
训练
./examples/cifar10/train_nobias.sh
会得到两个文件
cifar10_full_nobias_iter_40000.caffemodelcifar10_full_nobias_iter_40000.solverstate
以下是在caffe-master中的过程
cd caffe-master
./data/cifar10/get_cifar10.sh #该脚本会下载二进制的cifar,并解压,会在/data/cifar10中出现很多batch文件 ./examples/cifar10/create_cifar10.sh #运行后将会在examples中出现数据集./cifar10_xxx_lmdb和数据集图像均值./mean.binaryprot
训练
./examples/cifar10/train_quick.sh
会得到两个文件
cifar10_quick_iter_4000.caffemodel.h5 cifar10_quick_iter_4000.solverstate.h5
检测
python python/classify.py examples/images/cat.jpg #这是用ImageNet模型检测的
python python/classify.py --model_def examples/cifar10/cifar10_quick.prototxt --pretrained_model examples/cifar10/cifar10_quick_iter_4000.caffemodel.h5 --center_only examples/images/cat.jpg foo #这是用我们自己的模型检测的
可能会出现的问题:
运行classify.py时报错 Mean shape incompatible with input shape
解决:
修改 ./python/caffe/io.py 文件
将
if ms != self.inputs[in_][1:]: raise ValueError('Mean shape incompatible with input shape.')
修改为:
if ms != self.inputs[in_][1:]: print(self.inputs[in_]) in_shape = self.inputs[in_][1:] m_min, m_max = mean.min(), mean.max() normal_mean = (mean - m_min) / (m_max - m_min) mean = resize_image(normal_mean.transpose((1,2,0)), in_shape[1:]).transpose((2,0,1)) (m_max - m_min) + m_min
即可.
以下为运行结果:
为了能够显示测试图片种类以及置信度,网上有位网友写了一个classify.py
地址:http://download.csdn.net/detail/caisenchuan/9513196
下载后替换Python/classify.py
因为这个classify.py增加了几个参数 –labels_file、–print_results、–force_grayscale可以显示预测结果,同时博主发现这个文件有问题,你直接运行是输出不了结果的,需要修改171行
'synset_id': l.strip().split(' ')[0], 'name': ' '.join(l.strip().split(' ')[1:]).split(',')[0]
修改为
'name': l.strip().split(' ')[0],'synset_id': ' '.join(l.strip().split(' ')[1:]).split(',')[0]
之后cd到caffe-master,终端运行
python python/classify.py --print_results --model_def examples/cifar10/cifar10_quick.prototxt --pretrained_model examples/cifar10/cifar10_quick_iter_4000.caffemodel.h5 --labels_file data/cifar10/batches.meta.txt --center_only examples/images/cat.jpg foo
显示结果
1 0
- BWN-XNOR-caffe-master训练二进制cifar数据集
- 我的第一个二值化网络:BWN-XNOR-caffe安装注意项&&BWN-XNOR-caffe-master训练二进制cifar数据集
- BWN-XNOR-caffe安装注意项
- Ubuntu+caffe训练cifar-10数据集
- caffe学习(二) CIFAR-10数据集上训练
- caffe示例实现之1在CIFAR-10数据集上训练与测试Caffe
- caffe训练CIFAR数据库
- 利用caffe训练cifar之训练数据集合生成leveldb
- Windows Caffe 学习笔记(一)训练和测试CIFAR-10数据集
- CIFAR-10数据集可视化二进制版本
- simpleCNN 训练 cifar-10 数据集
- 深度学习Caffe平台实例——CIFAR-10数据集在caffe平台上模型训练及实例使用模型进行预测
- CIFAR-10 在Caffe上训练学习
- CIFAR-10在caffe上进行训练
- 使用Caffe + VGG16 训练 Cifar-10
- cifar数据集基于Caffe的生成与测试
- Cifar-10数据集的训练与测试
- caffe训练mnist数据集
- 九九乘法表来啦
- ACM春季讲座(一)笔记
- bzoj2463谁能赢呢?(博弈论)
- 动态规划初学
- css-position
- BWN-XNOR-caffe-master训练二进制cifar数据集
- Node.js 开发框架比较
- 2017-03-17
- AndroidStudio上离线使用Gradle
- 零审美Web前端系列——(00)导语
- HDU 1020 Encoding
- Linux命令行登录防止MySQL密码泄露的几个小妙招
- Self-introduction
- SQL优化