!5226 Modify the problem of dividing by 0

Merge pull request !5226 from shenwei41/sw_master
This commit is contained in:
mindspore-ci-bot 2020-08-26 17:03:24 +08:00 committed by Gitee
commit 3be1011397
4 changed files with 12 additions and 4 deletions

View File

@ -60,6 +60,14 @@ def check_value(value, valid_range, arg_name=""):
valid_range[1]))
def check_value_normalize_std(value, valid_range, arg_name=""):
arg_name = pad_arg_name(arg_name)
if value <= valid_range[0] or value > valid_range[1]:
raise ValueError(
"Input {0}is not within the required interval of ({1} to {2}).".format(arg_name, valid_range[0],
valid_range[1]))
def check_range(values, valid_range, arg_name=""):
arg_name = pad_arg_name(arg_name)
if not valid_range[0] <= values[0] <= values[1] <= valid_range[1]:

View File

@ -105,7 +105,7 @@ class RandomSharpness(cde.RandomSharpnessOp):
Raises:
TypeError : If degrees is not a list or tuple.
ValueError: If degrees is not positive.
ValueError: If degrees is negative.
ValueError: If degrees is in (max, min) format instead of (min, max).
Examples:

View File

@ -224,7 +224,7 @@ class Normalize:
"""
Normalize the input Numpy image array of shape (C, H, W) with the given mean and standard deviation.
The values of the array need to be in range [0.0, 1.0].
The values of the array need to be in range (0.0, 1.0].
Args:
mean (sequence): List or tuple of mean values for each channel, w.r.t channel order.

View File

@ -22,7 +22,7 @@ from mindspore._c_dataengine import TensorOp
from .utils import Inter, Border, ImageBatchFormat
from ...core.validator_helpers import check_value, check_uint8, FLOAT_MAX_INTEGER, check_pos_float32, \
check_2tuple, check_range, check_positive, INT32_MAX, parse_user_args, type_check, type_check_list, \
check_tensor_op, UINT8_MAX
check_tensor_op, UINT8_MAX, check_value_normalize_std
def check_crop_size(size):
@ -92,7 +92,7 @@ def check_normalize_py_param(mean, std):
for mean_value in mean:
check_value(mean_value, [0., 1.], "mean_value")
for std_value in std:
check_value(std_value, [0., 1.], "std_value")
check_value_normalize_std(std_value, [0., 1.], "std_value")
def check_fill_value(fill_value):