参考Caffe source中examples/cifar10目录下内容。

cifar10是一个用于普通物体识别的数据集,cifar10被分为10类,分别为airplane、automobile、bird、cat、deer、dog、frog、horse、ship、truck,关于cifar10的详细介绍可以参考: http://blog.csdn.net/fengbingchun/article/details/53560637

调整后的cifar10_quick_solver.prototxt内容如下:

# reduce the learning rate after 8 epochs (4000 iters) by a factor of 10# The train/test net protocol buffer definition
net: "E:/GitCode/Caffe_Test/test_data/model/cifar10/cifar10_quick_train_test.prototxt"
# test_iter specifies how many forward passes the test should carry out.
# In the case of MNIST, we have test batch size 100 and 100 test iterations,
# covering the full 10,000 testing images.
test_iter: 100
# Carry out testing every 500 training iterations.
test_interval: 500
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.001
momentum: 0.9
weight_decay: 0.004
# The learning rate policy
lr_policy: "fixed"
# Display every 100 iterations
display: 100
# The maximum number of iterations
max_iter: 4000
# snapshot intermediate results
snapshot: 4000
snapshot_format: HDF5
snapshot_prefix: "E:/GitCode/Caffe_Test/test_data/model/cifar10/cifar10_quick"
# solver mode: CPU or GPU
#solver_mode: GPU

调整后的cifar10_quick_train_test.prototxt内容如下:

name: "CIFAR10_quick"
layer {name: "cifar"type: "Data"top: "data"top: "label"include {phase: TRAIN}transform_param {mean_file: "E:/GitCode/Caffe_Test/test_data/model/cifar10/mean.binaryproto"}data_param {source: "E:/GitCode/Caffe_Test/test_data/cifar10/cifar10_train_lmdb"batch_size: 100backend: LMDB}
}
layer {name: "cifar"type: "Data"top: "data"top: "label"include {phase: TEST}transform_param {mean_file: "E:/GitCode/Caffe_Test/test_data/model/cifar10/mean.binaryproto"}data_param {source: "E:/GitCode/Caffe_Test/test_data/cifar10/cifar10_test_lmdb"batch_size: 100backend: LMDB}
}
layer {name: "conv1"type: "Convolution"bottom: "data"top: "conv1"param {lr_mult: 1}param {lr_mult: 2}convolution_param {num_output: 32pad: 2kernel_size: 5stride: 1weight_filler {type: "gaussian"std: 0.0001}bias_filler {type: "constant"}}
}
layer {name: "pool1"type: "Pooling"bottom: "conv1"top: "pool1"pooling_param {pool: MAXkernel_size: 3stride: 2}
}
layer {name: "relu1"type: "ReLU"bottom: "pool1"top: "pool1"
}
layer {name: "conv2"type: "Convolution"bottom: "pool1"top: "conv2"param {lr_mult: 1}param {lr_mult: 2}convolution_param {num_output: 32pad: 2kernel_size: 5stride: 1weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"}}
}
layer {name: "relu2"type: "ReLU"bottom: "conv2"top: "conv2"
}
layer {name: "pool2"type: "Pooling"bottom: "conv2"top: "pool2"pooling_param {pool: AVEkernel_size: 3stride: 2}
}
layer {name: "conv3"type: "Convolution"bottom: "pool2"top: "conv3"param {lr_mult: 1}param {lr_mult: 2}convolution_param {num_output: 64pad: 2kernel_size: 5stride: 1weight_filler {type: "gaussian"std: 0.01}bias_filler {type: "constant"}}
}
layer {name: "relu3"type: "ReLU"bottom: "conv3"top: "conv3"
}
layer {name: "pool3"type: "Pooling"bottom: "conv3"top: "pool3"pooling_param {pool: AVEkernel_size: 3stride: 2}
}
layer {name: "ip1"type: "InnerProduct"bottom: "pool3"top: "ip1"param {lr_mult: 1}param {lr_mult: 2}inner_product_param {num_output: 64weight_filler {type: "gaussian"std: 0.1}bias_filler {type: "constant"}}
}
layer {name: "ip2"type: "InnerProduct"bottom: "ip1"top: "ip2"param {lr_mult: 1}param {lr_mult: 2}inner_product_param {num_output: 10weight_filler {type: "gaussian"std: 0.1}bias_filler {type: "constant"}}
}
layer {name: "accuracy"type: "Accuracy"bottom: "ip2"bottom: "label"top: "accuracy"include {phase: TEST}
}
layer {name: "loss"type: "SoftmaxWithLoss"bottom: "ip2"bottom: "label"top: "loss"
}

cifar10_quick_train_test.prototxt可视化结果如下图(http://ethereon.github.io/netscope/quickstart.html):

训练代码如下: 它既可以在CPU也可以在GPU模式下运行,分别对应的工程为Caffe_Test和Caffe_GPU_Test,在GPU模式下耗时较少。

#include "funset.hpp"
#include "common.hpp"int cifar10_train()
{
#ifdef CPU_ONLYcaffe::Caffe::set_mode(caffe::Caffe::CPU);
#elsecaffe::Caffe::set_mode(caffe::Caffe::GPU);
#endifconst std::string filename{ "E:/GitCode/Caffe_Test/test_data/model/cifar10/cifar10_quick_solver.prototxt" };caffe::SolverParameter solver_param;if (!caffe::ReadProtoFromTextFile(filename.c_str(), &solver_param)) {fprintf(stderr, "parse solver.prototxt fail\n");return -1;}cifar10_convert(); // convert cifar10 to LMDBif (cifar10_compute_image_mean() != 0) { // compute cifar10 image mean, generate mean.binaryprotofprintf(stderr, "compute cifar10 image mean fail\n");return -1;}caffe::SGDSolver<float> solver(solver_param);solver.Solve();fprintf(stderr, "cifar10 train finish\n");return 0;
}

执行结果如下图所示:

默认最大迭代次数为4000,此时accuracy为0.7062;如果设置最大迭代次数为10000,则此时accuracy约为0.72。

GitHub:https://github.com/fengbingchun/Caffe_Test

Caffe中对cifar10执行train操作相关推荐

  1. Caffe中对MNIST执行train操作执行流程解析

    之前在 http://blog.csdn.net/fengbingchun/article/details/49849225 中简单介绍过使用Caffe train MNIST的文章,当时只是仿照ca ...

  2. 离散结构和离散数学中文书_在离散数学中对场景执行的操作

    离散结构和离散数学中文书 Prerequisite: Set theory and types of set in Discrete Mathematics 先决条件: 离散数学中的集合论和集合类型 ...

  3. caffe中layer的一些特殊操作,比如split

    slice:在某一个维度,按照给定的下标,blob拆分成几块.比如要拆分channel,总数50,下标为10,20,30,40,那就是分成5份,每份10个channel,输出5个layer. conc ...

  4. 该文件没有与之关联的程序来执行该操作_Liunx tty子系统分析之三 tty字符设备文件操作接口说明...

    本章主要介绍tty字符设备文件对应的操作接口,从而说明tty设备的数据打开.关闭.读.写等接口的实现等内容. tyy file_operations定义 tty字符设备文件操作接口的定义如下,主要包括 ...

  5. 在Android中使用Handler和Thread线程执行后台操作

    在 Android中使用Handler和Thread线程执行后台操作 对于线程的控制,我们将介绍一个 Handler类,使用该类可以对运行在不同线程中的多个任务进行排队,并使用Message和Runn ...

  6. Android中使用Handler和异步任务(AsyncTack)来为UI线程执行费时操作

    出于性能优化的考虑,Android的UI线程不是线程安全的.这致使我们不能在Android的UI线程中执行一些费时的操作,如下载.刷新等.Android中只允许UI线程对Activity中的UI组件进 ...

  7. android 每隔2秒执行_Android中实现延迟执行操作的三种方法

    今天在敲代码的过程中,有个需求是延迟执行某方法. 整理收集了三种方法,自己用的是第三种. 第一种线程休眠:new Thread() { @Override public void run() { su ...

  8. 在使用win 7 无线承载网络时,启动该服务时,有时会提示:组或资源的状态不是执行请求操作的正确状态。 网上有文章指出,解决这个问题的方法是在设备管理器中启动“Microsoft托管网络虚拟适配

    在使用win 7 无线承载网络时,启动该服务时,有时会提示:组或资源的状态不是执行请求操作的正确状态. 网上有文章指出,解决这个问题的方法是在设备管理器中启动"Microsoft托管网络虚拟 ...

  9. mybatis 执行插入操作,insert 返回1,数据库中无数据。数据库中数据的创建时间和插入执行时间不一致。

    大家好,我是烤鸭: 今天记录一下线上的问题,由于不是我们组的代码,所以没参与全程,只是最后有幸听各位大佬探讨解决方案.mybatis 执行插入操作,insert返回1,日志记录和接口返回都正常,但是数 ...

最新文章

  1. python估计物体角度
  2. collections python_python: collections
  3. FFmpeg简易播放器的实现5-音视频同步
  4. 虚拟化部署之Windows 7中远程管理Hyper-V
  5. 财务有必要学python吗-8年老财务:财务分析学python就能提高效率?一半人是骗子...
  6. python方法调用名字不一样怎么办_python如何通过实例方法名字调用方法
  7. rapidxml对unicode的支持
  8. Layer表格复选框,禁止勾选某行
  9. Junos: 使用之前
  10. 简易版WoMic(二)
  11. 【工具分享】推荐一款超级好用的截图工具
  12. 微信小程序的微信开发者工具的快捷键查找和设置
  13. 色彩混合模型——两种三原色
  14. PHP生成缩略图、加水印
  15. curry化 js_Javascript函数柯里化(curry)
  16. 浅析Marshmallow在flask中的应用
  17. (生物信息学)R语言绘图初-中-高级——3-10分文章必备——Venn图(韦恩图)(初级)
  18. 【方法】Latex使用BibTeX生成参考文献列表
  19. 【编译原理】最小化 DFA
  20. 新出免费字体——阿里巴巴普惠字体(附安装使用教程)

热门文章

  1. 一文搞懂TCP的三次握手和四次挥手
  2. keras 的 example 文件 mnist_hierarchical_rnn.py 解析
  3. KMP-next数组
  4. 数据结构与算法(3-2)队列(顺序队列、循环队列与链队列)
  5. coreldraw水涟漪怎么做_凉皮调料水的做法 调凉皮的调料水怎么做
  6. Angular使用@Input和@Output实现父子组件互相传参(类似Vue的props和this.emit)
  7. Blender3.0电影级别CG场景制作视频教程
  8. Blender模块化建筑环境地形场景制作视频教程 Creating modular environments
  9. Overall Comparision With WCDMA
  10. 浅析对象访问属性的.和[]方法区别