local response normalization/batch normalization

来源:互联网 发布:深圳市市政院 知乎 编辑:程序博客网 时间:2024/06/07 00:10

local response normalization

先上公式,local response normalization (lrn) 是用于数据归一化的方法。Tensorflow 中对应 tf.nn.local_response_normalization.


假设输入是 [batch_size, height, width, channels], 那么lrn实际上是对某一个像素位置(x,y),某一个batch_size,在channels的维度进行归一化,j 对应 channels 值。其他都是参数。该方法不如下面的batch normalization 效果好。


tf.nn.local_response_normalization(input, depth_radius=none, bias=none, alpha=none, beta=none, name=none)

input: [batch_size, height, width, channels]

depth_radius: 归一化半径


batch normalization

batch normalization 也是用于数据归一化,公式如下。


下面说明如何计算,先借鉴一张图,出处点这里。




均值和方差的计算是对每一个kernel来算的,就是固定channels那一维,然后求所有像素点的均值和方差,用于归一化。该方法好、快,至于为什么好、快,请转这里。大致就是归一化后较接近拟合的初始线,所以经过的迭代过程少。


tf.nn.moments(x, axes, shift=none, name=none, keep_dims=False)

x: [batch_size, height, width, channels]

axes: 需要固定的维度,在这里应该是最后一维

keep_dims: False 则返回一维的均值和方差向量,与channels的大小相同;True 则返回四维矩阵,只不过除了       

                    channels,其他维都为1


tf.nn.batch_normalization(x, mean, variance, offset, scale, variance_epsilon, name=none)

x: [batch_size, height, width, channels]

mean/variance: 上面返回的均值和方差,两种形式都可以

offset: beta

scale: gamma

variance_epsilon: a small float number to avoid dividing by 0


更多详细内容参看下面链接:

谈谈Tensorflow的Batch Normalization

深度学习(二十九)Batch Normalization 学习笔记

解读Batch Normalization



0 0