caffe


原文链接: caffe

https://github.com/k5iogura/mobilenetv2_ssdlite_fs.git

https://github.com/SnailTyan/caffe-model-zoo.git

TensorFlow 模型合集,可以从这里找模型

Caffe使用教程train.prototxt详解(上)

Ubuntu 16.04 + Opencv3.0 + gtx1080 + caffe(SSD) + ROS(Kinetic) - zp9187 - CSDN博客

正常情况:
train loss 不断下降,test loss不断下降,说明网络仍在学习;
异常情况:
train loss 不断下降,test loss趋于不变,说明网络过拟合;
train loss 趋于不变,test loss不断下降,说明数据集100%有问题;
train loss 趋于不变,test loss趋于不变,说明学习遇到瓶颈,需要减小学习率或批量数目;
train loss 不断上升,test loss不断上升,说明网络结构设计不当,训练超参数设置不当,数据集经过清洗等问题。
————————————————
版权声明:本文为CSDN博主「ff哟」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43317842/article/details/87966347

pip install scikit-image

利用caffe的snapshot参数生成的.solverstate 在意外断电退出时继续训练

caffe可以在遇到突然断开时候重新训练。在训练的时候不仅会保存当前模型的参数(也就是caffemodel)文件,也会把训练到当前状态信息全部保存下来,这个文件就是solverstate文件。只要在训练的时候加上snapshot参数就可以了

./build/tools/caffe train --solver=models/bvlc_reference_caffenet/solver.prototxt --snapshot=models/bvlc_reference_caffenet/caffenet_train_iter_10000.solverstate

imagenet 生成图像的均值文件

caffe/examples/imagenet/make_imagenet_mean.sh
compute_image_mean vgg_train_lmdb/ imagenet_mean.binaryproto

1 使用方法

训练网络

caffe/build/tools/caffe train --solver xx/solver.prototxt
选择某个模型作为预训练模型

caffe/build/tools/caffe train --solver solver.protxt --weights pre_training.caffemodel
继续之前的状态续训

caffe/build/tools/caffe train --solver solver.protxt --snapshot=train_iter_95000.solverstate
画出网络结构

python /caffe/python/draw_net.py train_alex.prototxt alexnet.png
选择多gpu进行训练

caffe/build/tools/caffe train --solver xx/solver.prototxt --gpu=0,1
设置系统环境变量使所需GPU可见

export CUDA_VISIBLE_DEVICES=1
训练log保存

nohup caffe/build/tools/caffe train –solver solver.prototxt &
tail –f output
查看log中训练loss的值

cat output.log | grep "Train net output" | awk '{print $11}' > loss.log
其中,awk的 ‘{print $11}’ 是用来截取串中的第11个子串

2 常见使用过程报错含义

(1) errror: Check failed: error == cudaSuccess (2 vs. 0) out of memory

说明GPU内存不够用了,减少batch_size即可,参考

(2) error: ImportError: No module named pydot when python draw_net.py train_val.prototxt xxx.png

使用draw_net.py画图时所报的错误,需要安装graphviz

pip install pydot
pip install GraphViz
sudo apt-get install graphviz
(3) error: Cannot copy param 0 weights from layer 'fc8'; shape mismatch.

Source param shape is 5 4096 (20480); target param shape is 1000 4096 (4096000). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.

出现这个问题一般是层与层的之前blob维度对应不上,需要改prototxt

change deploy.prototxt adapt to train_val.prototxt
(4) error: Use hdf5 as caffe input, error: HDF5Data does not transform data

transform_param { scale: 0.00392156862745098 }

这句是说如果HDF5作为输入图像,不支持scale操作,把它注释就好了

Reference

(5) error: Loading list of HDF5 filenames from: failed to open source file

Read hdf5 data failed:

source中 .txt位置用绝对路径
.txt中.h5文件的要用绝对路径
.prototxt中应该是:hdf5_data_param {}而非data_param{}
(6) error: Top blob 'data' produced by multiple sources.

检查数据输入层是不是多了 一层,比如定义了两遍’data’

(7) Error: Check failed: shape[i] >= 0 (-1 vs. 0)

数据维度顺序不对, blobs的顺序: [ 图像数量 N 通道数 C 图像高度 H *图像宽度 W ]
kernerl size 与 feature map的大小不对应
(8) Error: Check failed: outernum * innernum == bottom[1]->count() (128 vs 128x51)

这层是accuracy layer出现的问题,检测accuracy的两个bottom的维度是否对应,实在解决不了的话,直接去掉

`