一、Batch Normalization 概念
Batch Normalization:批标准化
批:一批数据,通常为mini-batch
标准化:0均值,1方差
优点:
1、可以用更大学习率,加速模型收敛
2、可以不用精心设计权值初始化
3、可以不用dropout或较小的dropout
4、可以不用L2或者较小的weight decay
5、可以不用LRN(local response normalization)
计算方式
affine transform 增强Capacity
Internal Covariate Shift(ICS)
_BatchNorm
nn.BatchNorm1d
nn.BatchNorm2d
nn.BatchNorm3d
参数:
num_features:一个样本特征数量(最重要)
e p s:分母修正项
momentum:指数加权平均估计当前mean/var
affine:是否需要affine transform
track_running_stats:是训练状态,还是测试状态
主要属性:
running_mean:均值
running_var:方差
weight:affine transform中的gamma
bias:affine transform中的beta
nn.BatchNorm1d input = B*特征值*1d特征
nn.BatchNorm2d input = B*特征值*2d特征
nn.BatchNorm3d input = B*特征值*3d特征