局部响应归一化LRN

LRN首次是在2012的AlexNet当中使用,其中的意图是对局部神经元的活动创建竞争机制,使得其中响应比较大的值变得相对更大,并抑制其他反馈较小的神经元,增强了模型的泛化能力

下面是AlexNet论文中提及到的LRN

简要解释一下论文内容:

relus激活函数本身具有良好的特性,在输入的时候可能不需要归一化就能防止网络饱和,即网络可以连续训练下去。对于relus激活函数来讲,如果存在样本能够产生正向效果,对于该神经元就会学到内容。但是,作者们发现下面的局部归一化模式能够帮助提高泛化。用表示活跃的神经元,该神经元利用核i在位置(x,y)处计算得到,然后应用到ReLU非线性计算上。

其中n是在尺度空间中临近的核个数,N是该层核的总数(即通道数),其它都是一些超参数。

ai(x,y)表示在这个输出结构中的一个位置[a,b,c,d],可以理解成在某一张图中的某一个通道下的某个高度和某个宽度位置的点,即第a张图的第d个通道下的高度为b宽度为c的点。

从公式来看,特别注意一下∑叠加的方向是沿着通道方向的,即每个点值的平方和是沿着a中的第3维channel方向的,也就是一个点同方向的前面n/2个通道(最小为第0个通道)和后n/2个通道(最大为第d-1个通道)的点的平方和(共n+1个点)。即当前层的像素值会和前后各n/2层相关联,做归一化处理。

其中LRN的在tensorflow的实现如下:

@tf_export('nn.local_response_normalization', 'nn.lrn')
def lrn(input, depth_radius=5, bias=1, alpha=1, beta=0.5, name=None):
  r"""Local Response Normalization.

  The 4-D `input` tensor is treated as a 3-D array of 1-D vectors (along the last
  dimension), and each vector is normalized independently.  Within a given vector,
  each component is divided by the weighted, squared sum of inputs within
  `depth_radius`.  In detail,

      sqr_sum[a, b, c, d] =
          sum(input[a, b, c, d - depth_radius : d + depth_radius + 1] ** 2)
      output = input / (bias + alpha * sqr_sum) ** beta

  For details, see [Krizhevsky et al., ImageNet classification with deep
  convolutional neural networks (NIPS 2012)](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks).

  Args:
    input: A `Tensor`. Must be one of the following types: `half`, `bfloat16`, `float32`.
      4-D.
    depth_radius: An optional `int`. Defaults to `5`.
      0-D.  Half-width of the 1-D normalization window.
    bias: An optional `float`. Defaults to `1`.
      An offset (usually positive to avoid dividing by 0).
    alpha: An optional `float`. Defaults to `1`.
      A scale factor, usually positive.
    beta: An optional `float`. Defaults to `0.5`. An exponent.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `input`.
  """

 

下图是借用的图,通过图来解释:

当前的橘色框代表一个通道层,圆形的这个点是原始的输入值,那么要计算,就要找到该层对应的i与n/2的关系,i是橘色框的通道数,判断如果属于(0 , i+n/2),结果就是0到i+n/2之间的层上的值求平方和,对应到上图上其实是圆圈那个点的值用线上的一些列的值做归一化处理,至于选多少层和i,n这些参数有关。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值