caffe 预训练 或者Fine-Tuning 操作
1.使用预训练模型,需要修改训练的prototxt,将layer name改为与要使用模型的layer name相同即可。
Borrowing Weights from a Pretrained Network
To borrow the weights of an already trained model, we need to do two things:
- Rename our layer to match the name of the original model's layer. The weights are assigned by layer name, thus using the original network's layer name, we get it's weights.
For example, let say the original model had a layer name ip1, then we should name our layer ip1:
layer {
name: "ip1"
type: "InnerProduct"
bottom: "pool2"
top: "ip1"
param {
lr_mult:
}
param {
lr_mult:
}
inner_product_param {
num_output:
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
- Train our new hybrid model declaring the location of the weights:
caffe train —solver ourSolver.prototxt —weights theirModel.caffemodel
What About the Other Layers of Our Network?
The other layers of our network will be initialized just like any other brand new layer (usually ~zero).
2.Fine-Tuning 将prototxt某层的lr 置为0,这层即不学习
Fine-Tuning is the process of training specific sections of a network to improve results.
Making Layers Not Learn
To stop a layer from learning further, you can set it's param attributes in your prototxt.
For example:
layer {
name: "example"
type: "example"
...
param {
lr_mult: #learning rate of weights
decay_mult:
}
param {
lr_mult: #learning rate of bias
decay_mult:
}
}
参考:
https://github.com/BVLC/caffe/wiki/Fine-Tuning-or-Training-Certain-Layers-Exclusively
https://github.com/BVLC/caffe/wiki/Borrowing-Weights-from-a-Pretrained-Network
caffe 预训练 或者Fine-Tuning 操作的更多相关文章
- caffe fine tune 复制预训练model的参数和freeze指定层参数
复制预训练model的参数,只需要重新copy一个train_val.prototxt.然后把不需要复制的层的名字改一下,如(fc7 -> fc7_new),然后fine tune即可. fre ...
- (原)caffe中fine tuning及使用snapshot时的sh命令
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5946041.html 参考网址: http://caffe.berkeleyvision.org/tu ...
- 学习AI之NLP后对预训练语言模型——心得体会总结
一.学习NLP背景介绍: 从2019年4月份开始跟着华为云ModelArts实战营同学们一起进行了6期关于图像深度学习的学习,初步了解了关于图像标注.图像分类.物体检测,图像都目标物体检测等 ...
- zz从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史
从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史 Bert最近很火,应该是最近最火爆的AI进展,网上的评价很高,那么Bert值得这么高的评价吗?我个人判断是值得.那为什么 ...
- L23模型微调fine tuning
resnet185352 链接:https://pan.baidu.com/s/1EZs9XVUjUf1MzaKYbJlcSA 提取码:axd1 9.2 微调 在前面的一些章节中,我们介绍了如何在只有 ...
- 从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史(转载)
转载 https://zhuanlan.zhihu.com/p/49271699 首发于深度学习前沿笔记 写文章 从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史 张 ...
- pytorch预训练
Pytorch预训练模型以及修改 pytorch中自带几种常用的深度学习网络预训练模型,torchvision.models包中包含alexnet.densenet.inception.resnet. ...
- 【中文版 | 论文原文】BERT:语言理解的深度双向变换器预训练
BERT:Pre-training of Deep Bidirectional Transformers for Language Understanding 谷歌AI语言组论文<BERT:语言 ...
- 第二十四节,TensorFlow下slim库函数的使用以及使用VGG网络进行预训练、迁移学习(附代码)
在介绍这一节之前,需要你对slim模型库有一些基本了解,具体可以参考第二十二节,TensorFlow中的图片分类模型库slim的使用.数据集处理,这一节我们会详细介绍slim模型库下面的一些函数的使用 ...
随机推荐
- P3183 [HAOI2016]食物链
题目描述 如图所示为某生态系统的食物网示意图,据图回答第1小题现在给你n个物种和m条能量流动关系,求其中的食物链条数.物种的名称为从1到n编号M条能量流动关系形如a1 b1a2 b2a3 b3.... ...
- Twenproxy介绍
1 Twenproxy介绍 Twemproxy是为memcached或者Redis集群提供一个高速.轻量级代理服务.它的主要用途是降低对缓存server打开的连接数.它的主要特性例如以下: l 保持 ...
- SharePoint Search 分词(WordBreaker)
[问题] 我们经常会搜索一个很长的词,例如“国際協力銀行” ,对应的搜索结果中会有关于“国際”“協力”“銀行”相关内如都会搜索到,这样的行为就是分词,那如何知道搜索内如是如何分词的呢? [解决办法] ...
- 设计一个分布式RPC框架
0 前言 提前先祝大家春节快乐!好了,先简单聊聊. 我从事的是大数据开发相关的工作,主要负责的是大数据计算这块的内容.最近Hive集群跑任务总是会出现Thrift连接HS2相关问题,研究了解了下内部原 ...
- [iOS]拾遗补阙
一.AFNetworking POST纯字符串 修改位置AFURLRequestSerialization 修改前 NSString * AFQueryStringFromParameters(NSD ...
- “C++动态绑定”相关问题探讨
一.相关问题: 1. 基类.派生类的构造和析构顺序 2. 基类.派生类中virtual的取舍 二.测试代码: #include <iostream> class A { public: A ...
- mysql/mariadb学习过程中出现的问题与解决
mysql> insert into student values(,,'CS'); ERROR (): Duplicate entry ' for key 'PRIMARY'(duplecat ...
- python 3.x 实现简单用户登录
import os import sys import getpass login_username = 'admin' login_password = ' u = 0 while u < 3 ...
- CTF-i春秋网鼎杯第四场部分writeup
CTF-i春秋网鼎杯第四场部分writeup 因为我们组的比赛是在第四场,所以前两次都是群里扔过来几道题然后做,也不知道什么原因第三场的题目没人发,所以就没做,昨天打了第四场,简直是被虐着打. she ...
- mysql远程连接权限设置
今儿有位同事提出,一套MySQL 5.6的环境,从数据库服务器本地登录,一切正常,可是若从远程服务器访问,就会报错, ERROR 1045 (28000): Access denied for use ...