Browse Source

fix bugs

tags/v1.1.0
lihongkang 5 years ago
parent
commit
679651f344
6 changed files with 18 additions and 18 deletions
  1. +2
    -2
      mindspore/nn/layer/basic.py
  2. +1
    -1
      mindspore/nn/layer/lstm.py
  3. +7
    -7
      mindspore/nn/learning_rate_schedule.py
  4. +3
    -3
      mindspore/nn/loss/loss.py
  5. +1
    -1
      mindspore/nn/optim/adam.py
  6. +4
    -4
      mindspore/ops/operations/nn_ops.py

+ 2
- 2
mindspore/nn/layer/basic.py View File

@@ -364,13 +364,13 @@ class ClipByNorm(Cell):
where :math:`L_2(X)` is the :math:`L_2`-norm of :math:`X`.

Args:
axis (Union[None, int, tuple(int)): Compute the L2-norm along the Specific dimension.
axis (Union[None, int, tuple(int)]): Compute the L2-norm along the Specific dimension.
Default: None, all dimensions to calculate.

Inputs:
- **input** (Tensor) - Tensor of shape N-D. The type must be float32 or float16.
- **clip_norm** (Tensor) - A scalar Tensor of shape :math:`()` or :math:`(1)`.
Or a tensor shape can be broadcast to input shape.
Or a tensor shape can be broadcast to input shape.

Outputs:
Tensor, clipped tensor with the same shape as the input, whose type is float32.


+ 1
- 1
mindspore/nn/layer/lstm.py View File

@@ -101,7 +101,7 @@ class LSTM(Cell):
(num_directions * `num_layers`, batch_size, `hidden_size`).

Supported Platforms:
``GPU``
``Ascend`` ``GPU``

Examples:
>>> net = nn.LSTM(10, 12, 2, has_bias=True, batch_first=True, bidirectional=False)


+ 7
- 7
mindspore/nn/learning_rate_schedule.py View File

@@ -87,7 +87,7 @@ class ExponentialDecayLR(LearningRateSchedule):
>>> decay_rate = 0.9
>>> decay_steps = 4
>>> global_step = Tensor(2, mstype.int32)
>>> exponential_decay_lr = ExponentialDecayLR(learning_rate, decay_rate, decay_steps)
>>> exponential_decay_lr = nn.ExponentialDecayLR(learning_rate, decay_rate, decay_steps)
>>> result = exponential_decay_lr(global_step)
>>> print(result)
0.09486833
@@ -145,7 +145,7 @@ class NaturalExpDecayLR(LearningRateSchedule):
>>> decay_rate = 0.9
>>> decay_steps = 4
>>> global_step = Tensor(2, mstype.int32)
>>> natural_exp_decay_lr = NaturalExpDecayLR(learning_rate, decay_rate, decay_steps, True)
>>> natural_exp_decay_lr = nn.NaturalExpDecayLR(learning_rate, decay_rate, decay_steps, True)
>>> result = natural_exp_decay_lr(global_step)
>>> print(result)
0.1
@@ -204,10 +204,10 @@ class InverseDecayLR(LearningRateSchedule):
>>> decay_rate = 0.9
>>> decay_steps = 4
>>> global_step = Tensor(2, mstype.int32)
>>> inverse_decay_lr = InverseDecayLR(learning_rate, decay_rate, decay_steps, True)
>>> inverse_decay_lr = nn.InverseDecayLR(learning_rate, decay_rate, decay_steps, True)
>>> result = inverse_decay_lr(global_step)
>>> print(result)
0.06896552
0.1
"""
def __init__(self, learning_rate, decay_rate, decay_steps, is_stair=False):
super(InverseDecayLR, self).__init__()
@@ -252,7 +252,7 @@ class CosineDecayLR(LearningRateSchedule):
>>> max_lr = 0.1
>>> decay_steps = 4
>>> global_steps = Tensor(2, mstype.int32)
>>> cosine_decay_lr = CosineDecayLR(min_lr, max_lr, decay_steps)
>>> cosine_decay_lr = nn.CosineDecayLR(min_lr, max_lr, decay_steps)
>>> result = cosine_decay_lr(global_steps)
>>> print(result)
0.055
@@ -320,7 +320,7 @@ class PolynomialDecayLR(LearningRateSchedule):
>>> decay_steps = 4
>>> power = 0.5
>>> global_step = Tensor(2, mstype.int32)
>>> polynomial_decay_lr = PolynomialDecayLR(learning_rate, end_learning_rate, decay_steps, power)
>>> polynomial_decay_lr = nn.PolynomialDecayLR(learning_rate, end_learning_rate, decay_steps, power)
>>> result = polynomial_decay_lr(global_step)
>>> print(result)
0.07363961
@@ -388,7 +388,7 @@ class WarmUpLR(LearningRateSchedule):
>>> learning_rate = 0.1
>>> warmup_steps = 2
>>> global_step = Tensor(2, mstype.int32)
>>> warmup_lr = WarmUpLR(learning_rate, warmup_steps)
>>> warmup_lr = nn.WarmUpLR(learning_rate, warmup_steps)
>>> result = warmup_lr(global_step)
>>> print(result)
0.1


+ 3
- 3
mindspore/nn/loss/loss.py View File

@@ -303,9 +303,9 @@ class SampledSoftmaxLoss(_Loss):
- **weights** (Tensor) - Tensor of shape (C, dim).
- **bias** (Tensor) - Tensor of shape (C). The class biases.
- **labels** (Tensor) - Tensor of shape (N, num_true), type `int64, int32`. The
target classes.
- **inputs** (Tensor) - Tensor of shape (N, dim). The forward activations of
the input network.
target classes.
- **inputs** (Tensor) - Tensor of shape (N, dim). The forward activations of
the input network.

Outputs:
Tensor, a tensor of shape (N) with the per-example sampled softmax losses.


+ 1
- 1
mindspore/nn/optim/adam.py View File

@@ -273,7 +273,7 @@ class Adam(Optimizer):
Tensor[bool], the value is True.

Supported Platforms:
``Ascend``
``Ascend`` ``GPU``

Examples:
>>> net = Net()


+ 4
- 4
mindspore/ops/operations/nn_ops.py View File

@@ -1295,7 +1295,7 @@ class DepthwiseConv2dNative(PrimitiveWithInfer):
Examples:
>>> input = Tensor(np.ones([10, 32, 32, 32]), mindspore.float32)
>>> weight = Tensor(np.ones([1, 32, 3, 3]), mindspore.float32)
>>> depthwise_conv2d = ops.DepthwiseConv2dNative(channel_multiplier = 3, kernel_size = (3, 3))
>>> depthwise_conv2d = ops.DepthwiseConv2dNative(channel_multiplier=3, kernel_size=(3, 3))
>>> output = depthwise_conv2d(input, weight)
>>> print(output.shape)
(10, 96, 30, 30)
@@ -2417,7 +2417,7 @@ class ApplyRMSProp(PrimitiveWithInfer):
>>> input_x = Tensor(1., mindspore.float32)
>>> mean_square = Tensor(2., mindspore.float32)
>>> moment = Tensor(1., mindspore.float32)
>>> grad = Tensor(2., mindspore.float32 )
>>> grad = Tensor(2., mindspore.float32)
>>> learning_rate = Tensor(0.9, mindspore.float32)
>>> decay = 0.0
>>> momentum = 1e-10
@@ -4611,7 +4611,7 @@ class ApplyAdadelta(PrimitiveWithInfer):
>>> lr = Tensor(0.001, mstype.float32)
>>> rho = Tensor(0.0, mstype.float32)
>>> epsilon = Tensor(1e-6, mstype.float32)
>>> grad = Tensor(np.random.rand(1, 2).astype(np.float32))
>>> grad = Tensor(np.random.rand(2, 2).astype(np.float32))
>>> output = net(lr, rho, epsilon, grad)
>>> print(output)
(Tensor(shape=[2, 2], dtype=Float32, value=
@@ -5863,7 +5863,7 @@ class SparseApplyFtrl(PrimitiveWithCheck):
- **linear** (Tensor) - Tensor, has the same shape and data type as `linear`.

Supported Platforms:
``Ascend``
``Ascend`` ``GPU``

Examples:
>>> import mindspore


Loading…
Cancel
Save