caffe操作技巧
来源:互联网 发布:java实现发邮件带附件 编辑:程序博客网 时间:2024/04/28 23:39
查看网络结构:
(1)利用caffe自带的python,可以将*.prototxt保存为一张图片,
sudo python python/draw_net.py *.prototxt *.png --rankdir=BT(或者,TB,LR,RL)
(2)利用Netscope,可以生成网络结构,并带有详细信息,
http://ethereon.github.io/netscope/quickstart.html
http://ethereon.github.io/netscope/#/editor
随机初始化训练:
./build/tools/caffe train --solver=models/bvlc_reference_caffenet/solver.prototxt --gpu=-0,1
微调:
./build/tools/caffe train --solver=models/bvlc_reference_caffenet/solver.prototxt --weights=models/bvlc_reference_caffenet/caffenet_train_iter_10000.caffemodel--gpu=-0,1从中断处继续训练:
./build/tools/caffe train --solver=models/bvlc_reference_caffenet/solver.prototxt --snapshot=models/bvlc_reference_caffenet/caffenet_train_iter_10000.solverstate
统计在验证集(validation set)上的得分:
./build/tools/caffe test --model= models/bvlc_reference_caffenet/caffenet_train_iter_10000.prototxt--weights= models/bvlc_reference_caffenet/caffenet_train_iter_10000.caffemodel--gpu=0 --iterations=10000
统计训练时间:
# 在 CPU上, 10000iterations训练 caffenet的时间
./build/tools/caffe time --model= models/bvlc_reference_caffenet/caffenet_train_test.prototxt--iterations=10000
# 在 GPU上,默认的 50 iterations训练 caffenet的时间
./build/tools/caffe time --model= models/bvlc_reference_caffenet/caffenet_train_test.prototxt--gpu=0
# 在第一块 GPU上, 10000 iterations训练已给定权值的网络结构的时间
./build/tools/caffe time --model= models/bvlc_reference_caffenet/caffenet_train_test.prototxt--weights= models/bvlc_reference_caffenet/caffenet_train_iter_10000.caffemodel--gpu=0 --iterations=10000
查询GPU显卡参数信息:
# 查询第一块 GPU
./build/tools/caffe device_query --gpu=0
输出训练log日志到txt:
(1)GLOG_logtostderr=0 GLOG_log_dir=./Log/ ./build/tools /caffe train --solver=./deepid_solver.prototxt
(2) ./build/tools/caffe train --solver=./deepid_solver.prototxt >&log.txt&
解析日志:
会在当前文件夹下生成一个.train文件和一个.test文件
./TOOLS/extra/parse_log.sh *.log
生成曲线图:
./tools/extra/plot_training_log.py.example 0 *.png *.log
Notes:
1. Supporting multiple logs.
2. Log file name must end with the lower-cased ".log".
Supported chart types:
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
计算训练数据均值:
# sudo build/tools/compute_image_mean examples/mnist/mnist_train_lmdbexamples/mnist/mean.binaryproto
生成训练数据的LMDB文件:
convert_imageset [FLAGS] ROOTFOLDER/ LISTFILE DB_NAME
FLAGS:
--gray: 是否以灰度图的方式打开图片。程序调用opencv库中的imread()函数来打开图片,默认为false
--shuffle: 是否随机打乱图片顺序。默认为false
--backend:需要转换成的db文件格式,可选为leveldb或lmdb,默认为lmdb
--resize_width/resize_height: 改变图片的大小。在运行中,要求所有图片的尺寸一致,因此需要改变图片大小。程序调用opencv库的resize()函数来对图片放大缩小,默认为0,不改变
--check_size: 检查所有的数据是否有相同的尺寸。默认为false,不检查
--encoded: 是否将原图片编码放入最终的数据中,默认为false
--encode_type: 与前一个参数对应,将图片编码为哪一个格式:‘png','jpg'......
ROOTFOLDER:
图片的绝对路径
LISTFILE:
图片txt文件,格式为.txt,内容为,图片 标签
DB_NAME:
保存的文件名
build/tools/convert_imageset --shuffle --resize_height=256 --resize_width=256 /home/xxx/caffe/examples/images/ ./train.txt ./img_train_lmdb
matlab写caffe程序注意事项:
由于matlab的长宽和c++中opencv的长宽正好相反,同时matlab中是rgb通道,opencv中是bgr通道,因此,程序需要做这么2个变换。这里给出2种处理方式,
(1)直接调用caffe接口,
im_data =caffe.io.load_image('./examples/images/cat.jpg');
(2)用matlab函数自己实现,
im_data = imread('./examples/images/cat.jpg');% read image
im_data = im_data(:, :, [3, 2, 1]); % 从 RGB转换为 BGR
im_data = permute(im_data, [2, 1, 3]); % 改变 width与 height位置
im_data = single(im_data); % 转换为单精度
caffe模型转tensorflow工具:
https://github.com/ethereon/caffe-tensorflow
手动标注图像,生成VOC支持的XML文件工具:
https://github.com/tzutalin/labelImg
- caffe操作技巧
- Caffe操作技巧
- CAFFE-调试技巧
- caffe调参技巧
- caffe 使用小技巧
- caffe使用技巧
- Caffe操作技巧之如何快速准备自己的lmdb数据集
- caffe blob操作
- caffe 学c++ 编程 技巧
- ubuntu技巧--ubuntu caffe安装
- (Caffe)编程小技巧
- TMUX CAFFE等小技巧
- caffe模型训练小技巧
- 总结caffe调参技巧
- 操作技巧
- 操作技巧
- Caffe深度学习操作流程
- caffe接口及命令操作
- matlab 图片批量处理
- 蓝桥-树-图最小生成树2
- DDos防护系列之3--DDos防御系统
- mouseweel兼容火狐
- 关于字符串的输入总结
- caffe操作技巧
- 1063. Set Similarity (25)
- SQL模糊查询
- 跟我学SpringMVC目录汇总贴、PDF下载、源码下载
- python_使用matplotlib画饼状图(pie)
- 零基础学习hadoop生态系统到上手工作线路指导初级篇(HBASE篇)
- 输出九九乘法表
- Java 8系列之Stream中万能的reduce
- 2017.2.10【初中部 GDKOI】模拟赛B组 运算符(calc) 题解