@@ -1489,8 +1489,7 @@ def batch_norm(input,
1489
1489
name = None ,
1490
1490
moving_mean_name = None ,
1491
1491
moving_variance_name = None ,
1492
- average_mean = True ,
1493
- average_variance = True ):
1492
+ do_model_average_for_mean_and_var = False ):
1494
1493
"""
1495
1494
This function helps create an operator to implement
1496
1495
the BatchNorm layer using the configurations from the input parameters.
@@ -1519,12 +1518,15 @@ def batch_norm(input,
1519
1518
bias = helper .create_parameter (
1520
1519
attr = helper .bias_attr , shape = param_shape , dtype = dtype , is_bias = True )
1521
1520
1521
+ if do_model_average_for_mean_and_var :
1522
+ do_model_average_for_mean_and_var = None
1523
+
1522
1524
mean = helper .create_parameter (
1523
1525
attr = ParamAttr (
1524
1526
name = moving_mean_name ,
1525
1527
initializer = Constant (0.0 ),
1526
1528
trainable = False ,
1527
- average = average_variance ),
1529
+ do_model_average = do_model_average_for_mean_and_var ),
1528
1530
shape = param_shape ,
1529
1531
dtype = input .dtype )
1530
1532
mean .stop_gradient = True
@@ -1534,7 +1536,7 @@ def batch_norm(input,
1534
1536
name = moving_variance_name ,
1535
1537
initializer = Constant (1.0 ),
1536
1538
trainable = False ,
1537
- average = average_mean ),
1539
+ do_model_average = do_model_average_for_mean_and_var ),
1538
1540
shape = param_shape ,
1539
1541
dtype = input .dtype )
1540
1542
variance .stop_gradient = True
@@ -3352,14 +3354,14 @@ def reshape(x, shape, actual_shape=None, act=None, inplace=True, name=None):
3352
3354
Here are some examples to explain it.
3353
3355
3354
3356
1. Given a 3-D tensor x with a shape [2, 4, 6], and the target shape
3355
- is [6, 8], the reshape operator will transform x into a 2-D tensor with
3357
+ is [6, 8], the reshape operator will transform x into a 2-D tensor with
3356
3358
shape [6, 8] and leaving x's data unchanged.
3357
3359
3358
3360
2. Given a 3-D tensor x with a shape [2, 4, 6], and the target shape
3359
3361
specified is [2, 3, -1, 2], the reshape operator will transform x into a
3360
3362
4-D tensor with shape [2, 3, 4, 2] and leaving x's data unchanged. In this
3361
- case, one dimension of the target shape is set to -1, the value of this
3362
- dimension is inferred from the total element number of x and remaining
3363
+ case, one dimension of the target shape is set to -1, the value of this
3364
+ dimension is inferred from the total element number of x and remaining
3363
3365
dimensions.
3364
3366
3365
3367
3. Given a 3-D tensor x with a shape [2, 4, 6], and the target shape
@@ -3593,7 +3595,7 @@ def lrn(input, n=5, k=1.0, alpha=1e-4, beta=0.75, name=None):
3593
3595
def pad (x , paddings , pad_value = 0. , name = None ):
3594
3596
"""
3595
3597
Pads a tensor with a constant value given by :attr:`pad_value`, and the
3596
- padded width is specified by :attr:`paddings`.
3598
+ padded width is specified by :attr:`paddings`.
3597
3599
3598
3600
Specifically, the number of values padded before the contents of :attr:`x`
3599
3601
in dimension :attr:`i` is indicated by :attr:`paddings[i]`, and the number
@@ -3621,7 +3623,7 @@ def pad(x, paddings, pad_value=0., name=None):
3621
3623
x (Variable): The input tensor variable.
3622
3624
paddings (list): A list of integers. Its elements specify the padded
3623
3625
width before and after for each dimension in turn.
3624
- The length of :attr:paddings must be
3626
+ The length of :attr:paddings must be
3625
3627
:math:`rank(x) \\ times 2`.
3626
3628
pad_value (float): The constant value used to pad.
3627
3629
name(str|None): A name for this layer(optional). If set None, the layer
0 commit comments