caffe学习笔记17-find-tuning微调学习
2017-08-04 14:28
260 查看
find-tuning:
对已有模型进行find-tuning(softmax层的变动,只需要微调),比如我们现在有一个1000类的分类模型,但目前我们的需求仅是20类,此时我们不需要重新训练一个模型,只需要将最后一层换成20类的softmax层,然后使用已有数据对原模型进行fine-tuning即可。
1.Fine-tuning微调(train + solver.prototxt + caffemodel)
#
微调 CaffeNet 模型的权值以完成风格识别任务(style recognition)
./build/tools/caffe train -solver examples/finetuning_on_flickr_style/solver.prototxt -weights
models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
注:(变动的层fc8需要改名字,不然还是原来的参数,caffenet结构的输出层的类别数一定要大于我训练集的类别数才可以收敛!)
比如原来我把图像类别的label设置成1,2,3,改成0,1,2后,最后全连接层的转出改成3就OK了。
2.style recognition调参策略
1) we will change the name of the last layer form fc8 to fc8_flickr in our prototxt, it will begin training with random weights.
2)decrease base_lr(初始学习率,在train_val.protxt文件值中) and boost the lr_mult(局部学习倍率,conv和fc层才有) on the newly introduced layer(fc8_flickr).
3)set stepsize(solver.prototxt,迭代多少次就下降一次学习率) to a lower value. So the learning rate to Go down faster
4)So in the solver.prototxt,we can find the base_lr is 0.001 from 0.01,and the stepsize is become to 20000 from 100000.(重要)
base_lr: 0.001~0.01 (不改小,loss容易输出non)
lr_mult: w:10,b:20
stepsize: 20000~100000
3.进行微调训练分类时,loss一直是87.3365,可能的原因是:
1.标签的问题:
imagelist中,图像分类的标签label一定要从0开始,
分类层的 num_output 和 标签的值域 不符合:
a. 要知道imagenet是进行1000类的分类任务,我自己的数据是一个二分类,就一定要把最后‘fc8’InnerProduct的分类层的num_output: 2原来是1000,这个设成自己label的类别总数就可以。
b. 但是注意同时要修改train.prototxt和deploy.prototxt两个网络配置文件中的num_output
2.可能是学习率太高了
另外如果是最初的迭代的loss很小,然后突然变成87.3365。如果是这样,可以尝试一下调低学习率,我开始学习率是0.1,后来调成了0.001,反正就是调小,可以多试几次。
对已有模型进行find-tuning(softmax层的变动,只需要微调),比如我们现在有一个1000类的分类模型,但目前我们的需求仅是20类,此时我们不需要重新训练一个模型,只需要将最后一层换成20类的softmax层,然后使用已有数据对原模型进行fine-tuning即可。
1.Fine-tuning微调(train + solver.prototxt + caffemodel)
#
微调 CaffeNet 模型的权值以完成风格识别任务(style recognition)
./build/tools/caffe train -solver examples/finetuning_on_flickr_style/solver.prototxt -weights
models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
注:(变动的层fc8需要改名字,不然还是原来的参数,caffenet结构的输出层的类别数一定要大于我训练集的类别数才可以收敛!)
比如原来我把图像类别的label设置成1,2,3,改成0,1,2后,最后全连接层的转出改成3就OK了。
2.style recognition调参策略
1) we will change the name of the last layer form fc8 to fc8_flickr in our prototxt, it will begin training with random weights.
2)decrease base_lr(初始学习率,在train_val.protxt文件值中) and boost the lr_mult(局部学习倍率,conv和fc层才有) on the newly introduced layer(fc8_flickr).
3)set stepsize(solver.prototxt,迭代多少次就下降一次学习率) to a lower value. So the learning rate to Go down faster
4)So in the solver.prototxt,we can find the base_lr is 0.001 from 0.01,and the stepsize is become to 20000 from 100000.(重要)
base_lr: 0.001~0.01 (不改小,loss容易输出non)
lr_mult: w:10,b:20
stepsize: 20000~100000
3.进行微调训练分类时,loss一直是87.3365,可能的原因是:
1.标签的问题:
imagelist中,图像分类的标签label一定要从0开始,
分类层的 num_output 和 标签的值域 不符合:
a. 要知道imagenet是进行1000类的分类任务,我自己的数据是一个二分类,就一定要把最后‘fc8’InnerProduct的分类层的num_output: 2原来是1000,这个设成自己label的类别总数就可以。
b. 但是注意同时要修改train.prototxt和deploy.prototxt两个网络配置文件中的num_output
2.可能是学习率太高了
另外如果是最初的迭代的loss很小,然后突然变成87.3365。如果是这样,可以尝试一下调低学习率,我开始学习率是0.1,后来调成了0.001,反正就是调小,可以多试几次。
相关文章推荐
- caffe学习笔记17-find-tuning微调学习
- caffe学习笔记2:Fine-tuning一个类别识别的预处理的网
- 深度学习Caffe实战笔记(17)MATLAB实现卷积层卷积核权重的可视化
- 【深度学习】笔记17 windows下SSD网络在caffe中的配置(GPU版本)【笔记3】
- 学习笔记: pycaffe example 之 fine-tuning
- Caffe学习笔记(七)—— solver参数说明及利用自己的数据集对权值微调
- 【MongoDB学习笔记17】MongoDB的查询:find中的数组查询
- Caffe fine-tuning 微调网络 (记录加学习下)
- caffe学习笔记10 -- Fine-tuning a Pretrained Network for Style Recognitio
- 深度学习21天实战caffe学习笔记《17:学习资源>
- caffe学习笔记10.1--Fine-tuning a Pretrained Network for Style Recognition(new)
- CAFFE源码学习笔记之三-common
- CAFFE源码学习笔记之五-internal_thread
- 深度学习-21天实战caffe 笔记
- 黑马程序员—17—java基础:有关API的使用学习笔记和心得体会
- C语言学习笔记17——数组与指针
- caffe学习笔记2--caffe的文件结构
- 每天一个 linux 命令(17):文件查找命令 whereis 命令---学习笔记
- Caffe实例开发学习笔记。——网络配置文件 Layer参数详解——
- CAFFE源码学习笔记之七-layer_factory以及layer基类