【caffe】googlenet在windows下训练以及遇到的一系列问题——【caffe学习四】
来源:互联网 发布:linux的保存命令 编辑:程序博客网 时间:2024/05/18 03:01
大部分步骤可以参考上篇:http://blog.csdn.net/qq_15947787/article/details/78428478
本文在上篇的基础上进行说明,上篇是分5类,本文分4类
步骤1-4同上篇。
5.修改create_imagenet.sh内容:
与上篇不同的是RESIZE_HEIGHT与RESIZE_WIDTH修改为224
#!/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=224 RESIZE_WIDTH=224else 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."read
9.修改D:\caffe-train\models\bvlc_reference_caffenet下
solver.prototxt内容:
修改位置:
net路径
snapshot_prefix路径
等
net: "D:/caffe-train/models/bvlc_googlenet/train_val.prototxt"test_iter: 9test_interval: 100test_initialization: falsedisplay: 40average_loss: 40base_lr: 0.01lr_policy: "step"stepsize: 320gamma: 0.96max_iter: 10000momentum: 0.9weight_decay: 0.0002snapshot: 100snapshot_prefix: "D:/caffe-train/models/bvlc_googlenet"solver_mode: GPU
deploy.prototxt内容:
修改位置:
loss3/classifier层的num_output为分类数(一处)
layer { name: "loss3/classifier" type: "InnerProduct" bottom: "pool5/7x7_s1" top: "loss3/classifier" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4 #改成你的数据集类别数 weight_filler { type: "xavier" } bias_filler { type: "constant" value: 0 } }}
修改位置:
注释mean_value三行值,增加mean_file:路径(两处)
修改train和val的source路径(两处)
修改batch_size大小(两处)
修改输出loss1/classifier层,loss2/classifier层,loss3/classifier层的num_output为分类数(三处)
name: "GoogleNet"layer { name: "data" type: "Data" top: "data" top: "label" include { phase: TRAIN } transform_param { mirror: true crop_size: 224mean_file: "D:/caffe-train/data/imagenet_mean.binaryproto" #mean_value: 104 #mean_value: 117 #mean_value: 123 } data_param { source: "D:/caffe-train/data/img_train_lmdb" batch_size: 8 backend: LMDB }}layer { name: "data" type: "Data" top: "data" top: "label" include { phase: TEST } transform_param { mirror: false crop_size: 224mean_file: "D:/caffe-train/data/imagenet_mean.binaryproto" #mean_value: 104 #mean_value: 117 #mean_value: 123 } data_param { source: "D:/caffe-train/data/img_val_lmdb" batch_size: 50 #和solver中的test_iter相乘约等于验证集大小 backend: LMDB }}
layer { name: "loss1/classifier" type: "InnerProduct" bottom: "loss1/fc" top: "loss1/classifier" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4 #改成你的数据集类别数 weight_filler { type: "xavier" } bias_filler { type: "constant" value: 0 } }}
layer { name: "loss2/classifier" type: "InnerProduct" bottom: "loss2/fc" top: "loss2/classifier" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4 #改成你的数据集类别数 weight_filler { type: "xavier" } bias_filler { type: "constant" value: 0 } }}
layer { name: "loss3/classifier" type: "InnerProduct" bottom: "pool5/7x7_s1" top: "loss3/classifier" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4 #改成你的数据集类别数 weight_filler { type: "xavier" } bias_filler { type: "constant" value: 0 } }}
10.修改train_caffenet.bat内容:
tools\caffe.exe train --solver=D:\caffe-train\models\bvlc_googlenet\solver.prototxtpause
训练完成后,在D:\caffe-train\models下生成models。
—————————————————————————————————————————
问题1:top_k must be less than or equal to the number of classes
解决方法:由于我现在分的是4类,修改train_val.prototxt中top_k值为4,原值为5,有三处需要修改
—————————————————————————————————————————
问题2:Check failed: error == cudaSuccess (2 vs. 0) out of memory
解决方法:适当减小train_val.prototxt中batch_size大小
- 【caffe】googlenet在windows下训练以及遇到的一系列问题——【caffe学习四】
- 【caffe】caffenet在windows下训练以及遇到的一系列问题——【caffe学习二】
- 【caffe】caffe在windows用训练好的模型对单张图片测试——【caffe学习三】
- 深度学习实战——caffe windows 下训练自己的网络模型
- 深度学习实战——caffe windows 下训练自己的网络模型
- Caffe学习笔记(六)—— Windows下训练自己的数据
- Caffe学习笔记(四)——Windows 下caffe配置相关问题说明
- Windows Caffe 学习笔记(三)在Caffe上训练和测试自己的数据
- Windows下caffe训练自己的数据
- 【神经网络与深度学习】深度学习实战——caffe windows 下训练自己的网络模型
- 【caffe-Windows】caffe在Windows下训练深度学习网络并测试(以mnist为例)
- windows下caffe训练mnist
- Caffe 训练遇到的问题
- 【caffe-windows】在windows下编译caffe出现的问题
- Caffe学习笔记之 ——在Windows下的完全配置
- caffe练习实例(2)——cifar10在caffe上训练学习
- Windows环境下使用 Caffe在ImageNet上训练网络
- Windows caffe(四) 训练自己的图片数据
- 手把手教你vps,搭建属于自己的ss教程
- OneNote同步出错,组策略阻止
- Python常用函数与技巧总结(一)
- 英语之时间表示法
- 数据挖掘中的数据清洗方法大全
- 【caffe】googlenet在windows下训练以及遇到的一系列问题——【caffe学习四】
- 数据库的概念模型
- 定义模板
- Fresco实现图片放大
- 【DP】BAJ-Bytecomputer
- 张亦鸣: eBPF 简史
- 低照度图像修复方法总结
- 深入JVM内核—原理与优化之gc参数学习
- 汉诺塔1