【tensorflow】fine-tuning, 选择性加载ckpt部分权重
来源:互联网 发布:mac 远程vps 编辑:程序博客网 时间:2024/04/30 09:05
在上一篇的转载博客中http://blog.csdn.net/shwan_ma/article/details/78874696中,
我发现用slim可以很方便的选择性的从ckpt文件中加载所要的数据。
以我自己的代码为例:
exclude = ['layer_weight','WD2_conv', 'BD2']variables_to_restore=slim.get_variables_to_restore(exclude=exclude)self.saver = tf.train.Saver(variables_to_restore)self.saver.restore(self.sess, filename)
上述代码指的是除了权重名称为“layer_weight”,”WD2_conv”, “BD2”三种权重外,加载其他的权重。当然我不加载这些权重是为了更好的fine-tuning。
注意:
这是我犯的一个小错误,就是在保存重新训练的权重时,依然使用了之前的代码:
self.saver.save(self.sess, filename)
这会有问题的,之前我们在定义self.saver.save的时候,去除了“layer_weight”,”WD2_conv”, “BD2”三种权重,因此重新保存下来的也不会包含他们。
因此这里需要更改为:
self.saver = tf.train.Saver()self.saver.save(self.sess, filename)
需要重新定义saver,方能将所有训练好的权重进行保存
===============================================================================================分割线====================================
今天发现slim还有一种方法进行选择性加载ckpt部分权重:
exclude = ['layer_weight','WD2_conv', 'BD2']variables_to_restore = slim.get_variables_to_restore(exclude=exclude)init_fn = slim.assign_from_checkpoint_fn(filename, variables_to_restore)init_fn(self.sess)
阅读全文
0 0
- 【tensorflow】fine-tuning, 选择性加载ckpt部分权重
- 【tensorflow】选择性读取加载权重,fine-tuning
- tensorflow选择性读取权重
- Tensorflow Fine-Tuning 的一些说明
- fine-tuning
- tensorflow之inception_v3模型的部分加载及权重的部分恢复(23)---《深度学习》
- Caffe fine-tuning 学习
- YOLOv2如何fine-tuning?
- 深度学习fine-tuning
- YOLOv2如何fine-tuning?
- 为什么“Pretrained+Fine-tuning”
- fine-tuning的二三事
- CNN之fine-tuning
- 【tensorflow】在不同层上设置不同的学习率,fine-tuning
- tensorflow 加载部分变量
- 汇率“微调” rate fine-tuning
- Caffe fine-tuning 微调网络
- Caffe fine-tuning 微调网络
- opencv-2.4.9安装包及安装教程
- xxnet-deepin下使用
- spring could 配置中心
- 基于Vue的mqttws31.js连接mqtt服务器(WebSocket)
- 第一篇文章
- 【tensorflow】fine-tuning, 选择性加载ckpt部分权重
- 【day01】【环境】JAVA开发环境搭建
- Tensorflow GPU安装指南 (Ubuntu 16.04 anaconda cuda8.0 cuDNN6.0)
- ADO.NET生成100个1-100之间的不重复的随机数
- 数据挖掘_数据流挖掘
- 有关linux驱动学习
- javaScript遍历对象的属性值
- python模块系列之
- Spring源码-IOC(一)