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. 初识Qt鼠标、键盘事件及定时器和随机数

    1.新建Qt Gui应用,项目名称为“myEvent”,基类名称为QWidget,类名称为Widget. 2.widget.h文件中添加以下代码,该段代码中包含了三个事件函数和一个槽函数 privat ...

  2. PAT乙级1001

    https://pintia.cn/problem-sets/994805260223102976/problems/994805325918486528 #include<bits/stdc+ ...

  3. NYOJ 18 The Triangle 填表法,普通dp

    题目链接: http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid=18 The Triangle 时间限制:1000 ms  |  内存限制:6553 ...

  4. caffe 安装记录

    为了使用caffe,特地装了linux系统,版本:Ubuntu14.04 X64 可参照 http://www.cnblogs.com/platero/p/3993877.html 这个博客写的更好h ...

  5. 404 Note Found 队- BETA 版冲刺前准备

    目录 过去存在的问题 任务分工 规范 后端总结 卉卉 家灿 前端总结 绪佩 青元 恺琳 宇恒 丹丹 算法&API接口 家伟 鸿杰 一好 文档&博客撰写 政演 产品功能 我们已经坐了哪些 ...

  6. javascript---我对闭包的理解

    一.闭包       闭包是一种特殊的对象.它由两部分构成:函数,以及创建该函数的环境.环境由闭包创建时在作用域中的任何局部变量组成. 如何理解这句话:以一个例子说明;(from MDN) funct ...

  7. Mac端 Open GL初探

    一.环境配置 1.创建macOS工程 2.添加OpenGL.framework和GLUT.framework两个系统库 3.拖入资源文件 如果libGLTools.a问价先拖入到工程其他位置,后再移到 ...

  8. 目标反射回波检测算法及其FPGA实现 之三:平方、积分电路及算法的顶层实现

    目标反射回波检测算法及其FPGA实现之三: 平方.积分电路及算法的顶层实现 前段时间,接触了一个声呐目标反射回波检测的项目.声呐接收机要实现的核心功能是在含有大量噪声的反射回波中,识别出发射机发出的激 ...

  9. Openssl自建CA

    查看证书相关指令 # 查看公钥数字证书 openssl x509 -in cacert.pem -noout -text # 查看私钥数字证书 openssl pkcs12 -in client-ce ...

  10. lua虚拟机概述

    何为虚拟机 用于模拟计算机运行的程序.是个中间层,它处于脚本语言和硬件之间的一个程序.每一门脚本语言都会有自己定义的opcode("操作码"),可以理解为这门程序自己定义的&quo ...