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 操作的更多相关文章

  1. caffe fine tune 复制预训练model的参数和freeze指定层参数

    复制预训练model的参数,只需要重新copy一个train_val.prototxt.然后把不需要复制的层的名字改一下,如(fc7 -> fc7_new),然后fine tune即可. fre ...

  2. (原)caffe中fine tuning及使用snapshot时的sh命令

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5946041.html 参考网址: http://caffe.berkeleyvision.org/tu ...

  3. 学习AI之NLP后对预训练语言模型——心得体会总结

    一.学习NLP背景介绍:      从2019年4月份开始跟着华为云ModelArts实战营同学们一起进行了6期关于图像深度学习的学习,初步了解了关于图像标注.图像分类.物体检测,图像都目标物体检测等 ...

  4. zz从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史

    从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史 Bert最近很火,应该是最近最火爆的AI进展,网上的评价很高,那么Bert值得这么高的评价吗?我个人判断是值得.那为什么 ...

  5. L23模型微调fine tuning

    resnet185352 链接:https://pan.baidu.com/s/1EZs9XVUjUf1MzaKYbJlcSA 提取码:axd1 9.2 微调 在前面的一些章节中,我们介绍了如何在只有 ...

  6. 从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史(转载)

    转载 https://zhuanlan.zhihu.com/p/49271699 首发于深度学习前沿笔记 写文章   从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史 张 ...

  7. pytorch预训练

    Pytorch预训练模型以及修改 pytorch中自带几种常用的深度学习网络预训练模型,torchvision.models包中包含alexnet.densenet.inception.resnet. ...

  8. 【中文版 | 论文原文】BERT:语言理解的深度双向变换器预训练

    BERT:Pre-training of Deep Bidirectional Transformers for Language Understanding 谷歌AI语言组论文<BERT:语言 ...

  9. 第二十四节,TensorFlow下slim库函数的使用以及使用VGG网络进行预训练、迁移学习(附代码)

    在介绍这一节之前,需要你对slim模型库有一些基本了解,具体可以参考第二十二节,TensorFlow中的图片分类模型库slim的使用.数据集处理,这一节我们会详细介绍slim模型库下面的一些函数的使用 ...

随机推荐

  1. Service通信

    1.简介 Service通信是双向的, 它不仅可以发送消息, 同时还会有反馈. 所以service包括两部分, 一部分是请求方( Clinet) , 另一部分是应答方/服务提供方( Server) . ...

  2. java的重载 和重写

    请看如下代码: 父类: public class FU { public void show(){ System.out.println("this is fu!"); } } 子 ...

  3. ZooKeeper(二)Java API使用

    ZooKeeper官网提供了Java和C的API. 本文使用Java API来实现ZooKeeper的基本操作. 前言 下图中的Replicated Database是包含完整数据树(entire d ...

  4. 最近邻规则分类(k-Nearest Neighbor )机器学习算法python实现

    综述 Cover和Hart在1968年提出了最初的近邻算法 是分类(classification)算法 输入基于实例的学习(instance-based learning),惰性学习(lazy lea ...

  5. 愤怒的小鸟【$DP$优化】

    卡常的状压\(DP\),愤怒的小鸟. 其实本来是个很水的状压\(DP\),但因为最后三个点\(n=18\),成功地把我的不可能达到的下界为\(\Omega(2^nn^2)\),紧确的上界为\(O(2^ ...

  6. css学习之LInk & import

    一.用link加载外部样式表 1.放置位置:放在head元素中 2.样式表中只能包含样式规则,不能包含其他标记语言.如出现了标记,会导致其中一部分或全部被忽略. 3.type = 'text/css' ...

  7. java crm 进销存 springmvc SSM 项目 系统 源码

    系统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3  SSM ...

  8. MapReduce详解及shuffle阶段

    hadoop1.x和hadoop2.x的区别: Hadoop1.x版本: 内核主要由Hdfs和Mapreduce两个系统组成,其中Mapreduce是一个离线分布式计算框架,由一个JobTracker ...

  9. SEO优化上首页之搜索引擎原理内容处理与索引

    上文<搜索引擎原理SEO优化上首页之蜘蛛Spider>详细介绍了蜘蛛的分类.抓取入口.抓取策略和更新策略.搜索引擎已把页面抓取回来,接下来是解析页面内容,主要包含判断页面类型.提取页面主题 ...

  10. Verilog_Day2

    Verilog_Day1 在CSDN博客上.http://blog.csdn.net/m0_38073085 第三章: 书上基本知识 每个Verilog程序包括4个主要部分:端口定义,I/O说明,内部 ...