From d0c7ece681c7cc6a4724b2e84c2273959fbb6d23 Mon Sep 17 00:00:00 2001 From: jiangjinsheng Date: Thu, 2 Jul 2020 15:33:34 +0800 Subject: [PATCH] fix HistogramFixedWidth --- mindspore/ops/operations/array_ops.py | 4 +--- mindspore/ops/operations/math_ops.py | 3 ++- mindspore/ops/operations/nn_ops.py | 5 ++++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mindspore/ops/operations/array_ops.py b/mindspore/ops/operations/array_ops.py index daefea64c..0e1456c25 100644 --- a/mindspore/ops/operations/array_ops.py +++ b/mindspore/ops/operations/array_ops.py @@ -1371,11 +1371,9 @@ class UnsortedSegmentMin(PrimitiveWithInfer): """ Computes the minimum along segments of a tensor. - If the given segment_ids is negative, the value will be ignored. - Inputs: - **input_x** (Tensor) - The shape is :math:`(x_1, x_2, ..., x_R)`. - - **segment_ids** (Tensor) - A `1-D` tensor whose shape is :math:`(x_1)`. + - **segment_ids** (Tensor) - A `1-D` tensor whose shape is :math:`(x_1)`, the value should be >= 0. - **num_segments** (int) - The value spcifies the number of distinct `segment_ids`. Outputs: diff --git a/mindspore/ops/operations/math_ops.py b/mindspore/ops/operations/math_ops.py index 5198e912f..d7fa77787 100644 --- a/mindspore/ops/operations/math_ops.py +++ b/mindspore/ops/operations/math_ops.py @@ -1356,7 +1356,7 @@ class HistogramFixedWidth(PrimitiveWithInfer): Args: dtype (string): An optional attribute. Must be one of the following types: "int32", "int64". Default: "int32". - nbins (Tensor): Number of histogram bins, the type is int32. + nbins (int): Number of histogram bins, the type is positive integer. Inputs: - **x** (Tensor) - Numeric Tensor. Must be one of the following types: int32, float32, float16. @@ -1377,6 +1377,7 @@ class HistogramFixedWidth(PrimitiveWithInfer): @prim_attr_register def __init__(self, nbins, dtype='int32'): self.nbins = validator.check_value_type("nbins", nbins, [int], self.name) + validator.check_integer("nbins", nbins, 1, Rel.GE, self.name) valid_values = ['int32', 'int64'] self.dtype = validator.check_string("dtype", dtype, valid_values, self.name) self.init_prim_io_names(inputs=['x', 'range'], outputs=['y']) diff --git a/mindspore/ops/operations/nn_ops.py b/mindspore/ops/operations/nn_ops.py index c07f072f3..0247122c7 100644 --- a/mindspore/ops/operations/nn_ops.py +++ b/mindspore/ops/operations/nn_ops.py @@ -1738,6 +1738,8 @@ class SGD(PrimitiveWithInfer): @prim_attr_register def __init__(self, dampening=0.0, weight_decay=0.0, nesterov=False): validator.check_value_type("nesterov", nesterov, [bool], self.name) + if nesterov and dampening != 0: + raise ValueError(f"Nesterov need zero dampening!") self.init_prim_io_names(inputs=['parameters', 'gradient', 'learning_rate', 'accum', 'momentum', 'stat'], outputs=['output']) @@ -2151,7 +2153,8 @@ class ResizeBilinear(PrimitiveWithInfer): rescale by `new_height / height`. Default: False. Inputs: - - **input** (Tensor) - Image to be resized. Tensor of shape `(N_i, ..., N_n, height, width)`. + - **input** (Tensor) - Image to be resized. Tensor of shape `(N_i, ..., N_n, height, width)`, + with data type of float32 or float16. Outputs: Tensor, resized image. Tensor of shape `(N_i, ..., N_n, new_height, new_width)` in `float32`. -- GitLab