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 ...
随机推荐
- Laravel Homestead的安装和使用(照搬)
原文:https://blog.csdn.net/woqianduo/article/details/81091154/ 1.简介 1.1.Homestead是什么 Laravel Homestead ...
- 06CSS列表
CSS列表 列表样式——list-style-type list-style-type:<属性值> disc 黑圆点 circle 空心圆点 square 小黑方块 decimal ...
- left_v2.js
$(document).ready(function(){ $(".mc_left a").each(function(){ var href = $(this).attr(&qu ...
- 题解 洛谷P4035/BZOJ1013【[JSOI2008]球形空间产生器】
题目链接在这QvQ "你要求出这个n维球体的球心坐标",这使我想到的解方程...... 先假设n=2,这是一个二维平面.设圆心的坐标为\((x,y)\),有两个坐标\((a_1,b ...
- 【数据库】DML-增删改查-SQL实现
一.数据插入-Insert 1. 插入单条记录 insert into 表名(字段名,字段名,字段名) //当插入所有字段时,字段名可以省略 values('值1','值2','值3'); 2. 插入 ...
- 源码学习-Object类
1.Object类是Java所有类的超类 2.查看Object的属性和方法,发现Object类没有属性,只有13个方法,其中7个本地方法. 3.接下来看具体的方法 3.1 Object() 默认的构造 ...
- Redis 压缩存储的配置
如题,redis是采用了ziplist 元素在不足一定数量时采用压缩存储 hash: zset: list: 如上图所示: ziplist-entries:最大元素数量(即存储了多少个元素) zipl ...
- sqlite3 新建数据库的过程
有些东西,很简单,不过有坑,就变复杂了.我先说最简单的方法,新建一个空的txt文档,然后把后缀改为db就可以了.-_-蛋疼,其实一开始我是不知道的,也是后来成功新建db后发现db为0kb才大胆地做了这 ...
- idea 修改Git密码和账号方法
IDEA修改git账号及密码的方法: 1.file->settings->passwords 2.重启IDEA 3.执行一次提交或更新 当执行提交或更新之后,idea会自动提示输入账号.密 ...
- hdu 4770 状压+枚举
/* 长记性了,以后对大数组初始化要注意了!140ms 原来是对vis数组进行每次初始化,每次初始化要200*200的复杂度 一直超时,发现没必要这样,直接标记点就行了,只需要一个15的数组用来标记, ...