diff --git a/mindspore/nn/layer/container.py b/mindspore/nn/layer/container.py index a30634ce3b8..3e0cbd29fd2 100644 --- a/mindspore/nn/layer/container.py +++ b/mindspore/nn/layer/container.py @@ -149,13 +149,17 @@ class SequentialCell(Cell): """Appends a given cell to the end of the list. Examples: - >>> conv = nn.Conv2d(3, 2, 3, pad_mode='valid') - >>> bn = nn.BatchNorm2d(2) - >>> relu = nn.ReLU() - >>> seq = nn.SequentialCell([conv, bn]) - >>> seq.append(relu) - >>> x = Tensor(np.random.random((1, 3, 4, 4)), dtype=mindspore.float32) - >>> seq(x) + >>> conv = nn.Conv2d(3, 2, 3, pad_mode='valid') + >>> bn = nn.BatchNorm2d(2) + >>> relu = nn.ReLU() + >>> seq = nn.SequentialCell([conv, bn]) + >>> seq.append(relu) + >>> x = Tensor(np.ones([1, 3, 4, 4]), dtype=mindspore.float32) + >>> seq(x) + [[[[0.12445523 0.12445523] + [0.12445523 0.12445523]] + [[0. 0. ] + [0. 0. ]]]] """ if _valid_cell(cell): self._cells[str(len(self))] = cell diff --git a/mindspore/nn/learning_rate_schedule.py b/mindspore/nn/learning_rate_schedule.py index d40eaac5a3e..02102437550 100644 --- a/mindspore/nn/learning_rate_schedule.py +++ b/mindspore/nn/learning_rate_schedule.py @@ -61,8 +61,13 @@ class ExponentialDecayLR(LearningRateSchedule): .. math:: decayed\_learning\_rate[i] = learning\_rate * decay\_rate^{p} - Where :math:`p = \frac{current\_step}{decay\_steps}`, if `is_stair` is True, the formula - is :math:`p = floor(\frac{current\_step}{decay\_steps})`. + Where : + .. math:: + p = \frac{current\_step}{decay\_steps} + + If `is_stair` is True, the formula is : + .. math:: + p = floor(\frac{current\_step}{decay\_steps}) Args: learning_rate (float): The initial value of learning rate. @@ -110,8 +115,13 @@ class NaturalExpDecayLR(LearningRateSchedule): .. math:: decayed\_learning\_rate[i] = learning\_rate * e^{-decay\_rate * p} - Where :math:`p = \frac{current\_step}{decay\_steps}`, if `is_stair` is True, the formula - is :math:`p = floor(\frac{current\_step}{decay\_steps})`. + Where : + .. math:: + p = \frac{current\_step}{decay\_steps} + + If `is_stair` is True, the formula is : + .. math:: + p = floor(\frac{current\_step}{decay\_steps}) Args: learning_rate (float): The initial value of learning rate. @@ -160,8 +170,13 @@ class InverseDecayLR(LearningRateSchedule): .. math:: decayed\_learning\_rate[i] = learning\_rate / (1 + decay\_rate * p) - Where :math:`p = \frac{current\_step}{decay\_steps}`, if `is_stair` is True, The formula - is :math:`p = floor(\frac{current\_step}{decay\_steps})`. + Where : + .. math:: + p = \frac{current\_step}{decay\_steps} + + If `is_stair` is True, The formula is : + .. math:: + p = floor(\frac{current\_step}{decay\_steps}) Args: learning_rate (float): The initial value of learning rate. @@ -264,12 +279,14 @@ class PolynomialDecayLR(LearningRateSchedule): (1 - tmp\_step / tmp\_decay\_steps)^{power} + end\_learning\_rate Where : - .. math:: - `tmp\_step=min(current\_step, decay\_steps). - If `update_decay_steps` is true, update the value of `tmp_decay_step` every `decay_steps`. The formula is .. math:: - `tmp\_decay\_steps = decay\_steps * ceil(current\_step / decay\_steps)` + tmp\_step=min(current\_step, decay\_steps) + + If `update_decay_steps` is true, update the value of `tmp_decay_step` every `decay_steps`. The formula is : + + .. math:: + tmp\_decay\_steps = decay\_steps * ceil(current\_step / decay\_steps) Args: learning_rate (float): The initial value of learning rate. @@ -338,7 +355,10 @@ class WarmUpLR(LearningRateSchedule): .. math:: warmup\_learning\_rate[i] = learning\_rate * tmp\_step / warmup\_steps - Where :math:`tmp\_step=min(current\_step, warmup\_steps)`. + Where : + + .. math: + tmp\_step=min(current\_step, warmup\_steps) Args: learning_rate (float): The initial value of learning rate. diff --git a/mindspore/nn/probability/bijector/power_transform.py b/mindspore/nn/probability/bijector/power_transform.py index c14c493d7b2..3242ce6e9b0 100644 --- a/mindspore/nn/probability/bijector/power_transform.py +++ b/mindspore/nn/probability/bijector/power_transform.py @@ -41,8 +41,7 @@ class PowerTransform(Bijector): name (str): The name of the bijector. Default: 'PowerTransform'. param (dict): The parameters used to initialize the bijector. These parameters are only used when other Bijectors inherit from powertransform to pass in parameters. In this case the derived Bijector may overwrite - the argument `param`. - Default: None. + the argument `param`. Default: None. Examples: >>> # To initialize a PowerTransform bijector of power 0.5. diff --git a/mindspore/ops/operations/math_ops.py b/mindspore/ops/operations/math_ops.py index 47a5db3aae6..e421fd18265 100644 --- a/mindspore/ops/operations/math_ops.py +++ b/mindspore/ops/operations/math_ops.py @@ -127,8 +127,8 @@ class TensorAdd(_MathBinaryOp): Inputs: - **input_x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool, or a tensor whose data type is number or bool. - - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, - or a bool when the first input is a tensor, or a tensor whose data type is number or bool. + - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input + is a tensor, or a tensor whose data type is number or bool. Outputs: Tensor, the shape is the same as the one after broadcasting, @@ -1081,8 +1081,8 @@ class Sub(_MathBinaryOp): Inputs: - **input_x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool, or a tensor whose data type is number or bool. - - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, - or a bool when the first input is a tensor, or a tensor whose data type is number or bool. + - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input + is a tensor, or a tensor whose data type is number or bool. Outputs: Tensor, the shape is the same as the one after broadcasting, @@ -1159,9 +1159,8 @@ class SquaredDifference(_MathBinaryOp): Inputs: - **input_x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool, or a tensor whose data type is float16, float32, int32 or bool. - - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, - or a bool when the first input is a tensor or a tensor whose data type is - float16, float32, int32 or bool. + - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input + is a tensor or a tensor whose data type isfloat16, float32, int32 or bool. Outputs: Tensor, the shape is the same as the one after broadcasting, @@ -1865,8 +1864,8 @@ class TruncateDiv(_MathBinaryOp): Inputs: - **input_x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool, or a tensor whose data type is number or bool. - - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, - or a bool when the first input is a tensor, or a tensor whose data type is number or bool. + - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input + is a tensor, or a tensor whose data type is number or bool. Outputs: Tensor, the shape is the same as the one after broadcasting, @@ -1895,8 +1894,8 @@ class TruncateMod(_MathBinaryOp): Inputs: - **input_x** (Union[Tensor, Number, bool]) - The first input is a number, or a bool, or a tensor whose data type is number or bool. - - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, - or a bool when the first input is a tensor, or a tensor whose data type is number or bool. + - **input_y** (Union[Tensor, Number, bool]) - The second input is a number, or a bool when the first input + is a tensor, or a tensor whose data type is number or bool. Outputs: Tensor, the shape is the same as the one after broadcasting,