caffe系列学习博客网址

http://www.cnblogs.com/denny402/category/759199.html
根据这个教程里面还有需要注意的地方:
(1)(在creatfile_list.sh)文件中,path,data,my 这些路径一定不要写错了。
(2222) 还有就是如果你的图片不是以数字开头,也许需要改下

find $DATA/train -name "p*.bmp" | cut -d '/' -f4-5 | sed "s/$/ 0/">>$MY/train.txt
find $DATA/train -name "i*.bmp" | cut -d '/' -f4-5 | sed "s/$/ 1/">>$MY/train.txt

在train_val.prototxt文件根据修改后,如果你的分类不需要1000个,应该经下面的num_outpot改为相应的分类数量,同时从modeld文件夹下的bvlc_reference_caffenet文件下下复制deploy文件,因为你之前的sovel和train.val都是从这里复制的,因此需要从这里复制。并且也要修改里面的num_output。同时synsets.txt文件不需要1000行,仅仅留下你分类的行数,并标上名字。

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: 2
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}

(2)在开始训练的时候会出现restart data 这类命令,不要在意,让他自己慢慢运行就行,不用管。

按照教程执行后会生成model文件,就在caffe根目录下。以iterationxxx.model名字
还有下面的需要做:
deploy.prototxt自己复制并且改:
https://www.cnblogs.com/k7k8k91/p/7806232.html
同时记得这个修改一定要参照原来的东西,在dim dim dim dim 后面两个dim记得参照修改前的数值(227,227),不是256,也不是图像的实际大小。

之后还有一个文件叫synsets.txt
这个文件一定是需要的。

n01440764 car
n01443537 konglong
n01484850 daxiang
n01491361 hua
n01494475 ma
n01496331 6
n01498041
n01514668
n01514859
n01518878
n01530575
n01531178
n01532829
n01534433
n01537544
n01558993
n01560419
n01580077
n01582220
n01592084
n01601694
n01608432
n01614925
n01616318
n01622779
n01629819

由于原来的网络层的定义你最后的输出是1000,所以你的这个文件一定要有1000行,当然我们自己训练肯定是不需要分1000类的,我们仅仅需要根据你的图片分类顺序填上你的分类名称就好,多余的可以空着不填。

训练命令:

sudo build/tools/caffe train -solver examples/myfile/solver.prototxt

模型训练好后需要测试:

sudo ./build/examples/cpp_classification/classification.bin 
examples/myfile2/deploy.prototxt _iter_920.caffemodel
examples/myfile2/mean.binaryproto
examples/myfile2/synsets.txt data/re2/test/pic291.bmp

学习曲线可视化:
首先通过脚本训练网络:
新建一个.sh文件放在caffe目录下,开始训练

新建一个fan_train.sh文件放在caffe目录下,开始训练

#!/usr/bin/env sh  

set -e 

TOOLS=./build/tools

$TOOLS/caffe train --solver=./models/VGGNet/VOC0712/SSD_300x300/solver.prototxt
sudo运行生成log

sudo chmod u+x fan_train.sh 

./fan_train.sh >& fan.log & 

如果查看程序运行是否正常,使用下面这条语句

tail -f cifar.log

caffe本身提供了学习曲线的绘制程序:

./tools/extra/plot_training_log.py.example 0 learn_curve1.png ./dalunwenfuben2_back.log 
0: Test accuracy vs. Iters

1: Test accuracy vs. Seconds

2: Test loss vs. Iters

3: Test loss vs. Seconds

4: Train learning rate vs. Iters

5: Train learning rate vs. Seconds 6: Train loss vs. Iters 7: Train loss vs. Seconds
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值