分类训练数据集步骤:
-
标签文件放在 /home/wll/caffe/data/VOCdevkit/VOC2007/Annotations 文件夹下
-
图片数据集 /home/wll/caffe/data/VOCdevkit/VOC2007/JPEGImages 文件夹下
-
使用MATLAB根据比例生成
四个txt 放在/home/wll/caffe/data/VOCdevkit/VOC2007/ImageSets/Main文件下 -
修改/home/wll/caffe/data/VOC0712/labelmap_voc.prototxt文件类别
-
sh create_list.sh
create_data.sh -
训练指令:
SSD
./build/tools/caffe train -solver /home/wll/caffe/models/VGGNet/VOC0712/SSD_300x300/solver.prototxt -weights=/home/wll/caffe/models/VGGNet/squeezenet_v1.1.caffemodel 2>&1 |tee /home/wll/caffe/models/VGGNet/rizhi/train.log
VGG
./build/tools/caffe train -solver /home/wll/caffe/models/VGGNet/VOC0712/SSD_300x300/solver.prototxt -weights=/home/wll/caffe/models/VGGNet/VGG_ILSVRC_16_layers_fc_reduced.caffemodel 2>&1 |tee /home/wll/caffe/models/VGGNet/rizhi/train.log
发生中断时,继续训练指令:
./build/tools/caffe train --solver=models/VGGNet/VOC0712/SSD_300x300/solver.prototxt --snapshot=models/VGGNet/VOC0712/SSD_300x300/Squeezenet_VOC0712_SSD_300x300_iter_5000.solverstate
注:
Ctrl+F 出现搜索框
Ctrl+C 训练中断
修改参数:
1.test.prototxt和deploy.prototxt中mbox_conf_reshape层的最后一个dim,设置为为类别数
2.分别修改train.prototxt,test.prototxt(有两个)和deploy.prototxt中num_classes改为类别数
3.分别在train.prototxt,test.prototxt和deploy.prototxt中快捷键crl+F搜索mbox_conf,找到对应的层,修改参数num_output,共有6个,第1个设为为类别数×4,第2,3,4设为类别数×6,第6个设为为类别数×4
4…分别修改test.prototxt和deploy.prototxt中参数num_test_image为测试图片数
问题:
一:
I0216 10:16:50.461427 16036 solver.cpp:243] Iteration 60, loss = nan
I0216 10:16:50.461556 16036 solver.cpp:259] Train net output #0: mbox_loss = nan (* 1 = nan loss)
I0216 10:16:51.435171 16036 sgd_solver.cpp:138] Iteration 60, lr = 0.001
I0216 10:17:10.880903 16036 solver.cpp:243] Iteration 70, loss = nan
I0216 10:17:10.880944 16036 solver.cpp:259] Train net output #0: mbox_loss = nan (* 1 = nan loss)
损失值溢出,从网上找来的意见是修改base_lr,乘以0.1,改为0.0001
只是修改solver.prototxt中的参数,重新执行后base_lr没有改变,但是mbox_loss没有再出现=nan的情况。
ctrl+c中断程序后,再重新执行,需要删除/home/idc/deep/gjj/caffe/models/VGGNet/VOC0712/SSD_300x300路径下的临时文件,不然会从中断点继续执行。