|
|
|
@ -550,11 +550,13 @@ class _BatchNormBase(layers.Layer):
|
|
|
|
|
weight_attr=None,
|
|
|
|
|
bias_attr=None,
|
|
|
|
|
data_format='NCHW',
|
|
|
|
|
use_global_stats=None,
|
|
|
|
|
name=None):
|
|
|
|
|
super(_BatchNormBase, self).__init__()
|
|
|
|
|
self._num_features = num_features
|
|
|
|
|
self._weight_attr = weight_attr
|
|
|
|
|
self._bias_attr = bias_attr
|
|
|
|
|
self._use_global_stats = use_global_stats
|
|
|
|
|
|
|
|
|
|
if get_default_dtype() == 'float16':
|
|
|
|
|
set_default_dtype('float32')
|
|
|
|
@ -642,7 +644,8 @@ class _BatchNormBase(layers.Layer):
|
|
|
|
|
training=self.training,
|
|
|
|
|
momentum=self._momentum,
|
|
|
|
|
epsilon=self._epsilon,
|
|
|
|
|
data_format=self._data_format)
|
|
|
|
|
data_format=self._data_format,
|
|
|
|
|
use_global_stats=self._use_global_stats)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class BatchNorm1D(_BatchNormBase):
|
|
|
|
@ -694,6 +697,7 @@ class BatchNorm1D(_BatchNormBase):
|
|
|
|
|
will create ParamAttr as bias_attr. If it is set to Fasle, the weight is not learnable.
|
|
|
|
|
If the Initializer of the bias_attr is not set, the bias is initialized zero. Default: None.
|
|
|
|
|
data_format(str, optional): Specify the input data format, may be "NC", "NCL" or "NLC". Defalut "NCL".
|
|
|
|
|
use_global_stats(bool|None, optional): Whether to use global mean and variance. If set to False, use the statistics of one mini-batch, if set to True, use the global statistics, if set to None, use global statistics in the test phase and use the statistics of one mini-batch in the training phase. Default: None.
|
|
|
|
|
name(str, optional): Name for the BatchNorm, default is None. For more information, please refer to :ref:`api_guide_Name`..
|
|
|
|
|
|
|
|
|
|
Shape:
|
|
|
|
@ -784,6 +788,7 @@ class BatchNorm2D(_BatchNormBase):
|
|
|
|
|
will create ParamAttr as bias_attr. If it is set to Fasle, the weight is not learnable.
|
|
|
|
|
If the Initializer of the bias_attr is not set, the bias is initialized zero. Default: None.
|
|
|
|
|
data_format(str, optional): Specify the input data format, the data format can be "NCHW" or "NHWC". Default: NCHW.
|
|
|
|
|
use_global_stats(bool|None, optional): Whether to use global mean and variance. If set to False, use the statistics of one mini-batch, if set to True, use the global statistics, if set to None, use global statistics in the test phase and use the statistics of one mini-batch in the training phase. Default: None.
|
|
|
|
|
name(str, optional): Name for the BatchNorm, default is None. For more information, please refer to :ref:`api_guide_Name`..
|
|
|
|
|
|
|
|
|
|
Shape:
|
|
|
|
@ -872,6 +877,7 @@ class BatchNorm3D(_BatchNormBase):
|
|
|
|
|
will create ParamAttr as bias_attr. If it is set to Fasle, the weight is not learnable.
|
|
|
|
|
If the Initializer of the bias_attr is not set, the bias is initialized zero. Default: None.
|
|
|
|
|
data_format(str, optional): Specify the input data format, the data format can be "NCDHW" or "NDHWC. Default: NCDHW.
|
|
|
|
|
use_global_stats(bool|None, optional): Whether to use global mean and variance. If set to False, use the statistics of one mini-batch, if set to True, use the global statistics, if set to None, use global statistics in the test phase and use the statistics of one mini-batch in the training phase. Default: None.
|
|
|
|
|
name(str, optional): Name for the BatchNorm, default is None. For more information, please refer to :ref:`api_guide_Name`..
|
|
|
|
|
|
|
|
|
|
Shape:
|
|
|
|
|