【caffe】caffenet在windows下训练以及遇到的一系列问题——【caffe学习二】
来源:互联网 发布:java byte转16进制 编辑:程序博客网 时间:2024/05/21 07:59
继上篇http://blog.csdn.net/qq_15947787/article/details/78351390成功编译GPU版caffe后,尝试训练自己的样本。
以下整个工程可以下载,由于上传大小限制,分成了两部分上传:
http://download.csdn.net/download/qq_15947787/10051096
http://download.csdn.net/download/qq_15947787/10051099
1.新建文件夹caffe-train,将之前编译好的D:\caffe\scripts\build\tools\Release文件复制到caffe-train文件夹下,重命名为tools
2.将D:\caffe\models文件夹复制到caffe-train下。
3.制作样本,在caffe-train下新建data文件夹,放入制作好的样本及标签文件。一共5类,训练集每类80张图,测试集每类20张图。样本下载链接 http://download.csdn.net/download/qq_15947787/10050928
4.复制D:\caffe\examples\imagenet下create_imagenet.sh,make_imagenet_mean.sh,train_caffenet.sh到caffe-train下。
5.修改create_imagenet.sh内容:
完整的create_imagenet.sh内容为:
#!/usr/bin/env sh# Create the imagenet lmdb inputs# N.B. set the path to the imagenet train + val data dirsset -eEXAMPLE=dataDATA=dataTOOLS=toolsTRAIN_DATA_ROOT=data/train/VAL_DATA_ROOT=data/val/# Set RESIZE=true to resize the images to 256x256. Leave as false if images have# already been resized using another tool.RESIZE=trueif $RESIZE; then RESIZE_HEIGHT=256 RESIZE_WIDTH=256else RESIZE_HEIGHT=0 RESIZE_WIDTH=0fiif [ ! -d "$TRAIN_DATA_ROOT" ]; then echo "Error: TRAIN_DATA_ROOT is not a path to a directory: $TRAIN_DATA_ROOT" echo "Set the TRAIN_DATA_ROOT variable in create_imagenet.sh to the path" \ "where the ImageNet training data is stored." exit 1fiif [ ! -d "$VAL_DATA_ROOT" ]; then echo "Error: VAL_DATA_ROOT is not a path to a directory: $VAL_DATA_ROOT" echo "Set the VAL_DATA_ROOT variable in create_imagenet.sh to the path" \ "where the ImageNet validation data is stored." exit 1fiecho "Creating train lmdb..."GLOG_logtostderr=1 $TOOLS/convert_imageset \ --resize_height=$RESIZE_HEIGHT \ --resize_width=$RESIZE_WIDTH \ --shuffle \ $TRAIN_DATA_ROOT \ $DATA/train.txt \ $EXAMPLE/img_train_lmdbecho "Creating val lmdb..."GLOG_logtostderr=1 $TOOLS/convert_imageset \ --resize_height=$RESIZE_HEIGHT \ --resize_width=$RESIZE_WIDTH \ --shuffle \ $VAL_DATA_ROOT \ $DATA/val.txt \ $EXAMPLE/img_val_lmdbecho "Done."read6.运行create_imagenet.sh,在data下生成img_train_lmdb以及img_val_lmdb,运行过程中可能遇到问题1。
7.修改make_imagenet_mean.sh内容:
#!/usr/bin/env sh# Compute the mean image from the imagenet training lmdb# N.B. this is available in data/ilsvrc12EXAMPLE=dataDATA=dataTOOLS=tools$TOOLS/compute_image_mean $EXAMPLE/img_train_lmdb \ $DATA/imagenet_mean.binaryprotoecho "Done."read
8.运行make_imagenet_mean.sh,在data下生成imagenet_mean.binaryproto
9.修改D:\caffe-train\models\bvlc_reference_caffenet下
solver.prototxt内容:
net: "D:/caffe-train/models/bvlc_reference_caffenet/train_val.prototxt"test_iter: 20test_interval: 100base_lr: 0.01lr_policy: "step"gamma: 0.1stepsize: 100display: 20max_iter: 1000momentum: 0.9weight_decay: 0.0005snapshot: 500snapshot_prefix: "D:/caffe-train/models/bvlc_reference_caffenet"solver_mode: GPUtrain_val.prototxt内容:
mean_file以及source文件绝对路径,batch_size,fc8层num_output:5
name: "CaffeNet"layer { name: "data" type: "Data" top: "data" top: "label" include { phase: TRAIN } transform_param { mirror: true crop_size: 227 mean_file: "D:/caffe-train/data/imagenet_mean.binaryproto" }# mean pixel / channel-wise mean instead of mean image# transform_param {# crop_size: 227# mean_value: 104# mean_value: 117# mean_value: 123# mirror: true# } data_param { source: "D:/caffe-train/data/img_train_lmdb" batch_size: 128 backend: LMDB }}layer { name: "data" type: "Data" top: "data" top: "label" include { phase: TEST } transform_param { mirror: false crop_size: 227 mean_file: "D:/caffe-train/data/imagenet_mean.binaryproto" }# mean pixel / channel-wise mean instead of mean image# transform_param {# crop_size: 227# mean_value: 104# mean_value: 117# mean_value: 123# mirror: false# } data_param { source: "D:/caffe-train/data/img_val_lmdb" batch_size: 50 backend: LMDB }}layer { name: "conv1" type: "Convolution" bottom: "data" top: "conv1" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 96 kernel_size: 11 stride: 4 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } }}layer { name: "relu1" type: "ReLU" bottom: "conv1" top: "conv1"}layer { name: "pool1" type: "Pooling" bottom: "conv1" top: "pool1" pooling_param { pool: MAX kernel_size: 3 stride: 2 }}layer { name: "norm1" type: "LRN" bottom: "pool1" top: "norm1" lrn_param { local_size: 5 alpha: 0.0001 beta: 0.75 }}layer { name: "conv2" type: "Convolution" bottom: "norm1" top: "conv2" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 256 pad: 2 kernel_size: 5 group: 2 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 1 } }}layer { name: "relu2" type: "ReLU" bottom: "conv2" top: "conv2"}layer { name: "pool2" type: "Pooling" bottom: "conv2" top: "pool2" pooling_param { pool: MAX kernel_size: 3 stride: 2 }}layer { name: "norm2" type: "LRN" bottom: "pool2" top: "norm2" lrn_param { local_size: 5 alpha: 0.0001 beta: 0.75 }}layer { name: "conv3" type: "Convolution" bottom: "norm2" top: "conv3" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 384 pad: 1 kernel_size: 3 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } }}layer { name: "relu3" type: "ReLU" bottom: "conv3" top: "conv3"}layer { name: "conv4" type: "Convolution" bottom: "conv3" top: "conv4" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 384 pad: 1 kernel_size: 3 group: 2 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 1 } }}layer { name: "relu4" type: "ReLU" bottom: "conv4" top: "conv4"}layer { name: "conv5" type: "Convolution" bottom: "conv4" top: "conv5" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } convolution_param { num_output: 256 pad: 1 kernel_size: 3 group: 2 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 1 } }}layer { name: "relu5" type: "ReLU" bottom: "conv5" top: "conv5"}layer { name: "pool5" type: "Pooling" bottom: "conv5" top: "pool5" pooling_param { pool: MAX kernel_size: 3 stride: 2 }}layer { name: "fc6" type: "InnerProduct" bottom: "pool5" top: "fc6" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4096 weight_filler { type: "gaussian" std: 0.005 } bias_filler { type: "constant" value: 1 } }}layer { name: "relu6" type: "ReLU" bottom: "fc6" top: "fc6"}layer { name: "drop6" type: "Dropout" bottom: "fc6" top: "fc6" dropout_param { dropout_ratio: 0.5 }}layer { name: "fc7" type: "InnerProduct" bottom: "fc6" top: "fc7" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4096 weight_filler { type: "gaussian" std: 0.005 } bias_filler { type: "constant" value: 1 } }}layer { name: "relu7" type: "ReLU" bottom: "fc7" top: "fc7"}layer { name: "drop7" type: "Dropout" bottom: "fc7" top: "fc7" dropout_param { dropout_ratio: 0.5 }}layer { name: "fc8" type: "InnerProduct" bottom: "fc7" top: "fc8" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 5 weight_filler { type: "gaussian" std: 0.01 } bias_filler { type: "constant" value: 0 } }}layer { name: "accuracy" type: "Accuracy" bottom: "fc8" bottom: "label" top: "accuracy" include { phase: TEST }}layer { name: "loss" type: "SoftmaxWithLoss" bottom: "fc8" bottom: "label" top: "loss"}
10.修改train_caffenet.sh内容:
#!/usr/bin/env shset -eD:/caffe-train/tools/caffe.exe train \ --solver=D:/caffe-train/models/bvlc_reference_caffenet/solver.prototxt $@
11.运行train_caffenet.sh
备注,运行train_caffenet.sh感觉一卡一卡的,不如cmd来的痛快
在caffe-train打开cmd,输入指令:
tools\caffe.exe train --solver=D:\caffe-train\models\bvlc_reference_caffenet\solver.prototxt
———————————————————————————————————————————————————
问题1:运行create_imagenet.sh时,System entropy source not available, using fallback algorithm to generate seed instead. 然后后面一系列Could not open or find file xxx/xxx/xxx。具体如下图所示:
解决方法:在create_imagenet.sh中检查路径并没有错误,但是提示找不到图片,所以打开相应的train.txt以及val.txt 标签文件,选择文件—另存为—编码ANSI—保存。即可解决上述问题。另存为编码UNICODE上述问题就会出现。
- 【caffe】caffenet在windows下训练以及遇到的一系列问题——【caffe学习二】
- 【caffe】googlenet在windows下训练以及遇到的一系列问题——【caffe学习四】
- caffe----训练自己的图片caffenet模型
- 【caffe】caffe在windows用训练好的模型对单张图片测试——【caffe学习三】
- 深度学习实战——caffe windows 下训练自己的网络模型
- 深度学习实战——caffe windows 下训练自己的网络模型
- Caffe学习笔记(六)—— Windows下训练自己的数据
- caffe利用caffenet训练自己的图片数据
- Windows Caffe 学习笔记(三)在Caffe上训练和测试自己的数据
- Windows下caffe训练自己的数据
- caffe for windows的python接口学习(1):分析caffenet.py
- 【神经网络与深度学习】深度学习实战——caffe windows 下训练自己的网络模型
- 【caffe-Windows】caffe在Windows下训练深度学习网络并测试(以mnist为例)
- windows下caffe训练mnist
- Caffe 训练遇到的问题
- 【caffe-windows】在windows下编译caffe出现的问题
- Caffe学习笔记之 ——在Windows下的完全配置
- caffe for windows的matlab接口(二):进行训练以及绘制loss
- 机器学习第三章
- 问题 A: 输出梯形
- 2017.11.2测试
- ServletRequestListener请求的监听事件
- Hibernate中set元素相关属性详解
- 【caffe】caffenet在windows下训练以及遇到的一系列问题——【caffe学习二】
- leetcode:Integer to Roman 浅谈古罗马OI生活之数字的研究
- iOS 播放GIF动画
- 一周学习简单总结(二)
- js 数组转json,json转数组
- MVP注册登录
- Mybatis框架
- 使用Spring的@Scheduled实现定时任务
- Android 证书检测问题