!5226 Modify the problem of dividing by 0

Merge pull request !5226 from shenwei41/sw_master
pull/5226/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 3be1011397

@ -60,6 +60,14 @@ def check_value(value, valid_range, arg_name=""):
valid_range[1])) 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=""): def check_range(values, valid_range, arg_name=""):
arg_name = pad_arg_name(arg_name) arg_name = pad_arg_name(arg_name)
if not valid_range[0] <= values[0] <= values[1] <= valid_range[1]: if not valid_range[0] <= values[0] <= values[1] <= valid_range[1]:

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

@ -224,7 +224,7 @@ class Normalize:
""" """
Normalize the input Numpy image array of shape (C, H, W) with the given mean and standard deviation. 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: Args:
mean (sequence): List or tuple of mean values for each channel, w.r.t channel order. mean (sequence): List or tuple of mean values for each channel, w.r.t channel order.

@ -22,7 +22,7 @@ from mindspore._c_dataengine import TensorOp
from .utils import Inter, Border, ImageBatchFormat from .utils import Inter, Border, ImageBatchFormat
from ...core.validator_helpers import check_value, check_uint8, FLOAT_MAX_INTEGER, check_pos_float32, \ 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_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): def check_crop_size(size):
@ -92,7 +92,7 @@ def check_normalize_py_param(mean, std):
for mean_value in mean: for mean_value in mean:
check_value(mean_value, [0., 1.], "mean_value") check_value(mean_value, [0., 1.], "mean_value")
for std_value in std: 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): def check_fill_value(fill_value):

Loading…
Cancel
Save