Browse Source

fix example error

tags/v1.1.0
liangchenghui 5 years ago
parent
commit
1878a1b0f1
5 changed files with 20 additions and 11 deletions
  1. +1
    -1
      mindspore/nn/layer/pooling.py
  2. +4
    -1
      mindspore/ops/operations/__init__.py
  3. +6
    -5
      mindspore/ops/operations/array_ops.py
  4. +3
    -3
      mindspore/ops/operations/nn_ops.py
  5. +6
    -1
      mindspore/ops/operations/other_ops.py

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

@@ -371,7 +371,7 @@ class AvgPool1d(_PoolNd):
self.squeeze = P.Squeeze(2)

def construct(self, x):
_shape_check(self.shape(x))
x = F.depend(x, _shape_check(self.shape(x)))
batch, channel, width = self.shape(x)
if width == self.kernel_size[1]:
x = self.reduce_mean(x, 2)


+ 4
- 1
mindspore/ops/operations/__init__.py View File

@@ -82,7 +82,8 @@ from .nn_ops import (LSTM, SGD, Adam, FusedSparseAdam, FusedSparseLazyAdam, Appl
ApplyRMSProp, ApplyCenteredRMSProp, BasicLSTMCell, InTopK, UniformCandidateSampler)
from . import _quant_ops
from ._quant_ops import *
from .other_ops import (Assign, InplaceAssign, IOU, BoundingBoxDecode, BoundingBoxEncode, PopulationCount,
from .other_ops import (Assign, InplaceAssign, IOU, BoundingBoxDecode, BoundingBoxEncode,
ConfusionMatrix, PopulationCount,
CheckValid, MakeRefKey, Partial, Depend, identity, CheckBprop, Push, Pull)
from ._thor_ops import (CusBatchMatMul, CusCholeskyTrsm, CusFusedAbsMax1, CusImg2Col, CusMatMulCubeDenseLeft,
CusMatMulCubeFraczRightMul, CusMatMulCube, CusMatrixCombine, CusTranspose02314,
@@ -289,6 +290,7 @@ __all__ = [
'DepthwiseConv2dNative',
'UnsortedSegmentSum',
'UnsortedSegmentMin',
'UnsortedSegmentMax',
'UnsortedSegmentProd',
"AllGather",
"AllReduce",
@@ -377,6 +379,7 @@ __all__ = [
"UniformCandidateSampler",
"LRN",
"Mod",
"ConfusionMatrix",
"PopulationCount",
"ParallelConcat",
"Push",


+ 6
- 5
mindspore/ops/operations/array_ops.py View File

@@ -2104,18 +2104,19 @@ class Slice(PrimitiveWithInfer):
Slices a tensor in the specified shape.

Inputs:
x (Tensor): The target tensor.
begin (tuple): The beginning of the slice. Only constant value is allowed.
size (tuple): The size of the slice. Only constant value is allowed.
- **x** (Tensor): The target tensor.
- **begin** (tuple): The beginning of the slice. Only constant value is allowed.
- **size** (tuple): The size of the slice. Only constant value is allowed.

Returns:
Tensor.
Outputs:
Tensor, the shape is : input `size`, the data type is the same as input `x`.

Examples:
>>> data = Tensor(np.array([[[1, 1, 1], [2, 2, 2]],
>>> [[3, 3, 3], [4, 4, 4]],
>>> [[5, 5, 5], [6, 6, 6]]]).astype(np.int32))
>>> type = P.Slice()(data, (1, 0, 0), (1, 1, 3))
>>> print(type)
[[[3 3 3]]]
"""



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

@@ -5412,7 +5412,7 @@ class Dropout(PrimitiveWithInfer):

Args:
keep_prob (float): The keep rate, between 0 and 1, e.g. keep_prob = 0.9,
means dropping out 10% of input units.
means dropping out 10% of input units.

Inputs:
- **input** (Tensor) - The input tensor.
@@ -5426,9 +5426,9 @@ class Dropout(PrimitiveWithInfer):
>>> x = Tensor((20, 16, 50, 50), mindspore.float32)
>>> output, mask = dropout(x)
>>> print(output)
[ 0. 32. 0. 0.]
[0. 32. 0. 0.]
>>> print(mask)
[0. 1. 0. 0.]
[0. 1. 0. 0.]
"""

@prim_attr_register


+ 6
- 1
mindspore/ops/operations/other_ops.py View File

@@ -492,7 +492,12 @@ class ConfusionMatrix(PrimitiveWithInfer):
>>> confusion_matrix = P.ConfusionMatrix(4)
>>> labels = Tensor([0, 1, 1, 3], mindspore.int32)
>>> predictions = Tensor([1, 2, 1, 3], mindspore.int32)
>>> confusion_matrix(labels, predictions)
>>> output = confusion_matrix(labels, predictions)
>>> print(output)
[[0 1 0 0
[0 1 1 0]
[0 0 0 0]
[0 0 0 1]]
"""

@prim_attr_register


Loading…
Cancel
Save