Merge pull request !6396 from lijiaqi/modify_api
This commit is contained in:
mindspore-ci-bot 2020-09-18 09:58:46 +08:00 committed by Gitee
commit 1a69143412
3 changed files with 52 additions and 29 deletions

View File

@ -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

View File

@ -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.

View File

@ -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,