【学习笔记】Batch Norm in SNN

Batch Norm in SNN

对脉冲卷积神经网络进行基于时空域的标准化

Going Deeper With Directly-Trained Larger Spiking Neural Networks

背景

目前而言,行之有效的深度SNN训练方法大致有以下两种思路:

  1. 将预先训练好的ANN转换为SNN版本
    –> 该方法一般需要较长的脉冲编码窗口来达到收敛的效果
  2. 直接在时空域训练SNN
    –> 由于二元脉冲的激活函数问题以及梯度消失或爆炸问题导致网络层数不能过深

为解决后者存在的问题,提出了基于时空反向传播(spatio-temporal backpropagation, STBP)的,依赖于阈值的批标准化(threshold-dependent batch normalization method, tdBN)方法,称为"STBP-tdBN",能够直接训练网络非常深的SNN,并在相应硬件上有效实现推断。

具体实现

对于一个脉冲卷积神经网络(Spiking Convolution Neural Network, SCNN),时间步长t内前向传播过程如下:
x t = W ⊛ o t + B x_t = W \circledast o^t + B xt=Wot+B
其中 x t x_t xt为突触前输入信号(突触前膜输入信号的加权和,尚未经过IF模型产生输出脉冲), x t ∈ R N × C × H × W x^t\in R^{N\times C\times H\times W} xtRN×C×H×W

在tdBN算法中,将突触前输入依据其通道作相应的归一化。假定 x k t x^t_k xkt代表 x t x^t xt特征图的第k维,则 x k = ( x k 1 , x k 2 , ⋯   , x k T ) x_k=(x^1_k, x^2_k,\cdots,x^T_k) xk=(xk1,xk2,,xkT)将被标准化为:
x ^ k = α V t h ( x k − E [ x k ] ) V a r [ x k ] + ϵ \hat{x}_k=\frac{\alpha V_{th}(x_k-E[x_k])}{\sqrt{Var[x_k]+\epsilon}} x^k=Var[xk]+ϵ αVth(xkE[xk])

y k = λ k x ^ k + β k y_k=\lambda_k\hat{x}_k + \beta_k yk=λkx^k+βk

依定义有:
E [ x k ] = m e a n ( x k ) E[x_k]=mean(x_k) E[xk]=mean(xk)

V a r [ x k ] = m e a n ( ( x k − E [ x k ] ) 2 ) Var[x_k]=mean((x_k-E[x_k])^2) Var[xk]=mean((xkE[xk])2)

在这里插入图片描述

P.S. 把每个timestep得到的featuremap中第k通道分别取出,合并得到 x k x_k xk,后进行均值和方差的计算。

为避免“先卷积后BN”的操作增加不必要的计算量,可以利用batchnorm-scale-fusion的操作进行融合,从而将BN归并到卷积中。设若 W c , k W_{c, k} Wc,k B c , k B_{c, k} Bc,k,分别代表当前特征图c通道和下一特征图k通道之间的卷积核以及偏置项,则有:
W c , k ′ = λ k α V t h W c , k σ i n f , k 2 + ϵ W^\prime_{c, k} = \lambda_k\frac{\alpha V_{th}W_{c, k}} {\sqrt{\sigma^2_{inf, k}+\epsilon}} Wc,k=λkσinf,k2+ϵ αVthWc,k

B c , k ′ = λ k α V t h ( B c , k − μ i n f , k ) σ i n f , k 2 + ϵ + β k B^\prime_{c, k} = \lambda_k\frac{\alpha V_{th}(B_{c, k} - \mu_{inf, k})} {\sqrt{\sigma^2_{inf, k} + \epsilon}} + \beta_k Bc,k=λkσinf,k2+ϵ αVth(Bc,kμinf,k)+βk

简言之,tdBN与标准BN的主要区别有两处:

  1. 有别于ANN,SNN不仅逐层传播,同时逐时刻传播信息。因此stBN应当在时间和空间两个维度上对特征输入归一化。
  2. 归一化方差依赖于阈值的选择。在stBN中,pre-activations被标准化为 N ( 0 , ( α V t h ) 2 N(0, (\alpha V_{th})^2 N(0,(αVth)2,(一般常用标准化为0-1正态分布)
Spiking neural networks (SNNs) have advantages over traditional, non-spiking networks with respect to bio- realism, potential for low-power hardware implementations, and theoretical computing power. However, in practice, spiking net- works with multi-layer learning have proven difficult to train. This paper explores a novel, bio-inspired spiking convolutional neural network (CNN) that is trained in a greedy, layer-wise fashion. The spiking CNN consists of a convolutional/pooling layer followed by a feature discovery layer, both of which undergo bio-inspired learning. Kernels for the convolutional layer are trained using a sparse, spiking auto-encoder representing primary visual features. The feature discovery layer uses a probabilistic spike-timing-dependent plasticity (STDP) learning rule. This layer represents complex visual features using WTA- thresholded, leaky, integrate-and-fire (LIF) neurons. The new model is evaluated on the MNIST digit dataset using clean and noisy images. Intermediate results show that the convolutional layer is stack-admissible, enabling it to support a multi-layer learning architecture. The recognition performance for clean images is above 98%. This performance is accounted for by the independent and informative visual features extracted in a hierarchy of convolutional and feature discovery layers. The performance loss for recognizing the noisy images is in the range 0.1% to 8.5%. This level of performance loss indicates that the network is robust to additive noise
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值