Caffe框架,了解三个文件
来源:互联网 发布:jenkins mac 安装包 编辑:程序博客网 时间:2024/06/11 22:46
不知道从什么时候开始,Deep Learning成为了各个领域研究的热点,也不知道从什么时候开始,2015CVPR的文章出现了很多Deep Learning的文章,更不知道从什么时候开始,三维重建各个研究方向也要被Deep Learning攻破了。
从这个时候开始,我要开始学习Deep Learning了,因为我研究的方向已然被攻破!
以上是引言部分,下面开始介绍本文的内容。
我前段时间已经配置好Caffe这个框架,现在来摸索一下。本文分为两个部分,第一部分说明学习Caffe框架需要重点记住那些文件;第二部分使用Caffe框架对MNIST数据集进行训练学习。
一. Caffe框架文件
以‘$root’作为Caffe的主目录,以MNIST数据集训练学习作为例子,我觉得只要掌握三个文件就够了:
1. train_lenet.sh $root /examples/mnist/train_lenet.sh
#!/usr/bin/env sh./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt
使用caffe调用lenet_solver.prototxt进行train,’.prototxt’是一种文本文件,这里需要知道的是lenet_solver.prototxt是CNN网络学习的核心,下面我们将要学习它。
2. lenet_solver.prototxt $root /examples/mnist/lenet_solver.prototxt
# The train/test net protocol buffer definitionnet: "examples/mnist/lenet_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.01momentum: 0.9weight_decay: 0.0005# The learning rate policylr_policy: "inv"gamma: 0.0001power: 0.75# Display every 100 iterationsdisplay: 100# The maximum number of iterationsmax_iter: 10000# snapshot intermediate resultssnapshot: 5000snapshot_prefix: "examples/mnist/lenet"# solver mode: CPU or GPUsolver_mode: GPU
net: “examples/mnist/lenet_train_test.prototxt”是网络结构设置,其他部分是参数设置,看注释就很明白了。
3. lenet_train_test.prototxt $root /examples/mnist/lenet_train_test.prototxt
name: "LeNet"layer { name: "mnist" type: "Data" top: "data" top: "label" include { phase: TRAIN } transform_param { scale: 0.00390625 } data_param { source: "examples/mnist/mnist_train_lmdb" batch_size: 64 backend: LMDB }}layer { name: "mnist" type: "Data" top: "data" top: "label" include { phase: TEST } transform_param { scale: 0.00390625 } data_param { source: "examples/mnist/mnist_test_lmdb" batch_size: 100 backend: LMDB }}layer { name: "conv1" type: "Convolution" bottom: "data" top: "conv1" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 20 kernel_size: 5 stride: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } }}layer { name: "pool1" type: "Pooling" bottom: "conv1" top: "pool1" pooling_param { pool: MAX kernel_size: 2 stride: 2 }}layer { name: "conv2" type: "Convolution" bottom: "pool1" top: "conv2" param { lr_mult: 1 } param { lr_mult: 2 } convolution_param { num_output: 50 kernel_size: 5 stride: 1 weight_filler { type: "xavier" } bias_filler { type: "constant" } }}layer { name: "pool2" type: "Pooling" bottom: "conv2" top: "pool2" pooling_param { pool: MAX kernel_size: 2 stride: 2 }}layer { name: "ip1" type: "InnerProduct" bottom: "pool2" top: "ip1" param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 500 weight_filler { type: "xavier" } bias_filler { type: "constant" } }}layer { name: "relu1" type: "ReLU" bottom: "ip1" top: "ip1"}layer { name: "ip2" type: "InnerProduct" bottom: "ip1" top: "ip2" param { lr_mult: 1 } param { lr_mult: 2 } inner_product_param { num_output: 10 weight_filler { type: "xavier" } 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"}
这是各层网络的设置,看内容就知道了。需要注意的是,include {phase: TEST}是指测试网络,未标明的是train和test都可以使用。
二. MNIST数据集进行训练学习
cd $root./data/mnist/get_mnist.sh./examples/mnist/create_mnist.sh./examples/mnist/train_lenet.sh
get_mnist.sh下载MNIST数据集
create_mnist.sh将MNIST数据转换为lmdb格式的数据
在网络中的数据存储和操作是以Blobs形式
train_lenet.sh训练
参考:http://caffe.berkeleyvision.org/gathered/examples/mnist.html
- Caffe框架,了解三个文件
- 深入了解HelloAndroid下的三个文件
- caffe了解
- 深入了解HelloAndroid下的三个文件——转载出处:coder-pig
- 了解项目的三个角度
- 三个框架的原理
- CAffe框架的结构
- Caffe 框架介绍
- Caffe的框架
- Caffe 深度学习框架
- CAFFE框架训练
- 深度学习框架caffe
- caffe框架研究(一)
- Caffe框架初步理解
- Caffe、TensorFlow、MXnet三个开源库对比
- 【开源】Caffe、TensorFlow、MXnet三个开源库对比
- caffe源码解析的三个博客分享
- Caffe、TensorFlow、MXnet三个开源库对比
- 【SQLite关系型数据库管理系统】SQLite命令
- 【读书笔记】iOS-GCD-GCD与perfomSelector系方法比较
- 【Java数据结构】二分查找
- Kafka深入解析Log存储
- 实际试验遇到的一些python问题,包括图片格式转换,python中调用linux命令行,用python画图等等。
- Caffe框架,了解三个文件
- 未释放kafka资源导致的问题
- Theano里配置GPU的新方法
- Code First for Mysql 错误:未为提供程序“MySql.Data.MySqlClient”找到任何 MigrationSqlGenerator。请在目标迁移配置类中使用 SetSql
- CADisplayLink
- 招行网银常见问题汇总
- 单例模式
- C++单例模式实现方式
- 展讯SC7730:Camera兼容引起的打开失败问题