提交 7f8c9ebf 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!194 Fix dataset parameter check

Merge pull request !194 from pengyanjun/fix_dataset_para_validator_check
......@@ -127,7 +127,6 @@ class RandomSampler():
Raises:
ValueError: If replacement is not boolean.
ValueError: If num_samples is not None and replacement is false.
ValueError: If num_samples is not positive.
"""
......
......@@ -556,6 +556,11 @@ def check_generatordataset(method):
if column_names is None:
raise ValueError("column_names is not provided.")
# check prefetch_size range
prefetch_size = param_dict.get('prefetch_size')
if prefetch_size is not None and (prefetch_size <= 0 or prefetch_size > 1024):
raise ValueError("prefetch_size exceeds the boundary.")
check_param_type(nreq_param_int, param_dict, int)
check_param_type(nreq_param_list, param_dict, list)
......
......@@ -104,6 +104,10 @@ def check_padding(padding):
raise ValueError("The size of the padding list or tuple should be 2 or 4.")
else:
raise TypeError("Padding can be any of: a number, a tuple or list of size 2 or 4.")
if not (isinstance(left, int) and isinstance(top, int) and isinstance(right, int) and isinstance(bottom, int)):
raise TypeError("Padding value should be integer.")
if left < 0 or top < 0 or right < 0 or bottom < 0:
raise ValueError("Padding value could not be negative.")
return left, top, right, bottom
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册