tensorflow,torch tips
- apply weightDecay,L2 REGULARIZATION_LOSSES
weights = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
for w in weights:
print(w)
l2r = tf.contrib.layers.l2_regularizer(0.001)
tf.contrib.layers.apply_regularization(l2r,weights)
tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES) ##cross_entropy loss
tf.add_to_collection('losses', cross_entropy_mean)
loss = tf.add_n(tf.get_collection('losses'), name='cross_entropy_loss')
# config optimizer
target_loss = target_loss + tf.add_n(tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES),name='l2_loss')
train_step = tf.train.AdamOptimizer(
learning_rate).minimize(target_loss,global_step)
- .learningRateDecay
global_step = tf.Variable(0, trainable=False,name = 'global_step')
learning_rate = tf.train.exponential_decay(opts.learning_rate, global_step, 10000, 0.96, staircase=True)
train_step = tf.train.AdamOptimizer(learning_rate).minimize(target_loss,global_step)
- tensorflow 与torch 中 learningRateDecay的差异
torch:
-- (3) learning rate decay (annealing)
local clr = lr / (1 + state.t*lrd) state.t = state.t + 1 https://github.com/torch/optim/blob/master/adam.lua tensorflow:
decayed_learning_rate = learning_rate *
decay_rate ^ (global_step / decay_steps) https://www.tensorflow.org/versions/r0.11/api_docs/python/train/decaying_the_learning_rate
torch中是每个batch执行一次,如果lrd = 0.001
tensorflow 对应的应该是:decay_steps设为1,decay_steps = 1-lrd=0.999,这样就与torch的方法近似了?
不对,tesorflow中有等价的tf.train.inverse_time_decay
- tensorflow 中的softmax与torch 中LogSoftmax
tf.nn.softmax
exp(logits) / reduce_sum(exp(logits), dim)
tf.log(tf.nn.softmax(logits))并不与torch的LogSoftmax,torch中的LogSoftmax实现方式不一样:
https://github.com/torch/nn/blob/master/lib/THNN/generic/LogSoftMax.c
http://blog.csdn.net/lanchunhui/article/details/51248184
- saver
http://www.jianshu.com/p/8487db911d9a
- tensorflow 与torch 中 DropOut的差异
torch:
Furthermore, the outputs are scaled by a factor of 1/(1-p) during training. tensorflow:
With probability keep_prob, outputs the input element scaled up by 1 / keep_prob, otherwise outputs 0. The scaling is so that the expected sum is unchanged. 所以torch中的dropout_rate = p,相当于tesnsorflow中的keep_prob = 1-p
参数顺序
conv:torch outputs*inputs*kh*kw , tf kh*kw*inputs*outputs
deconv:torch inputs*outputs*kh*kw , tf kh*kw*outputs*inputs
移动端&MPS: outputs*kh*kw*inputs ,注意deconv kh*kw rotate 180度
tensorflow,torch tips的更多相关文章
- 『TensorFlow』专题汇总
TensorFlow:官方文档 TensorFlow:项目地址 本篇列出文章对于全零新手不太合适,可以尝试TensorFlow入门系列博客,搭配其他资料进行学习. Keras使用tf.Session训 ...
- 【深度学习Deep Learning】资料大全
最近在学深度学习相关的东西,在网上搜集到了一些不错的资料,现在汇总一下: Free Online Books by Yoshua Bengio, Ian Goodfellow and Aaron C ...
- 机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 2)
##机器学习(Machine Learning)&深度学习(Deep Learning)资料(Chapter 2)---#####注:机器学习资料[篇目一](https://github.co ...
- (转)Awesome Human Pose Estimation
Awesome Human Pose Estimation 2018-10-08 11:02:35 Copied from: https://github.com/cbsudux/awesome-hu ...
- 8.8 Deep Learning Software
深度学习软件 -CPU vs GPU -Deep Learning Framework - Caffe / Caffe2 - Theano / TensorFlow - Torch / PyTorch ...
- opencv::DNN介绍
DNN模块介绍: Tiny-dnn模块 支持深度学习框架 - Caffe - TensorFlow - Torch/PyTorch DNN运用 图像分类 对象检测 实时对象检测 图像分割 预测 视频对 ...
- YOLO---近段时间的练习目标
YOLO---近段时间的练习目标 yolo(darknet)官方主页:https://pjreddie.com/darknet/yolo/ 和在学校时用的不太一样了,有更新了- 还有一个常用版本: ...
- 【opencv系列01】OpenCV4.X介绍与安装
一.介绍 OpenCV(开源计算机视觉库:http://opencv.org)是英特尔开源的一个跨平台计算机视觉的BSD许可库,包含数百种计算机视觉算法.OpenCV由Gary Bradsky于199 ...
- CS231n 斯坦福李飞飞视觉识别课程
本文是个人在学习<CS231n 斯坦福李飞飞视觉识别课程>的学习笔记. 第一讲:课程简介 课时1 计算机视觉概述 课时2 计算机视觉历史背景 课时3 课程后勤 选读书籍<DeepLe ...
随机推荐
- 编译压缩代码 MFCompress-src-1.01 :对‘***’未定义的引用
提示 MFCompressD.o:在函数‘main’中:MFCompressD.c:(.text.startup+0x34a): 警告: the use of `tempnam' is dangero ...
- 检查sql对象是否存在
SQL Server判断对象是否存在 1 判断数据库是否存在 Sql代码 if exists (select * from sys.databases where name = '数据库名') ...
- JAVA基础——IO流字符流
字符流 字节流提供了处理任何类型输入/输出操作的功能(因为对于计算机而言,一切都是0和1,只需把数据以字节形式表示就够了),但它们不可以直接操作Unicode字符,因为上一篇文章写了,一个Unicod ...
- 配置Mysql审计
mysql-audit.json:Mysql审计日志 插件下载地址: https://bintray.com/mcafee/mysql-audit-plugin/release/1.1.4-725#f ...
- JavaScript:获取上传图片的base64
文章来源:http://www.cnblogs.com/hello-tl/p/7661535.html 1.HTML代码 <!DOCTYPE html> <html lang=&qu ...
- bootloader的移植
jz2440开发板 在介绍bootloader里边的内容的时候,需要知道的是: bootloader的引入的目的就是启动linux内核,一个简单的bootloader编写需要以下的步骤: ①初始化硬件 ...
- ASP.NET MVC的帮助类HtmlHelper和UrlHelper
在ASP.NET MVC框架中没有了自己的控件,页面显示完全就回到了写html代码的年代.还好在asp.net mvc框架中也有自带的HtmlHelper和UrlHelper两个帮助类.另外在MvcC ...
- Qt——信号与槽用法总结(未完待续)
1.设计模式中信号与槽编辑选项卡 2.右键组件,转到槽,写函数 void LoginDialog::on_loginBtn_clicked() { accept(); } 3.信号与槽编辑模式 按下F ...
- xtu summer individual 5 E - Burning Bridges
Burning Bridges Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Origina ...
- [TyvjP1050] 最长公共子序列(DP)
传送门 f[i][j] 表示第 1 个串匹配到第 i 位,第 2 个串匹配到第 j 位的答案. f[i][j] = max(f[i - 1][j], f[i][j - 1]) (a[i] != ...