!12469 [MD] fix bug in cifar10/100 to mindrecord

From: @liyong126
Reviewed-by: @savoygll,@heleiwang,@liucunwei
Signed-off-by: @savoygll,@liucunwei
pull/12469/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 7d554d4f78

@ -321,14 +321,16 @@ class Duplicate(cde.DuplicateOp):
class Unique(cde.UniqueOp): class Unique(cde.UniqueOp):
""" """
Return an output tensor containing all the unique elements of the input tensor in Perform the unique operation on the input tensor, only support transform one column each time.
the same order that they occur in the input tensor.
Also return an index tensor that contains the index of each element of the Return 3 tensor: unique output tensor, index tensor, count tensor.
input tensor in the Unique output tensor.
Finally, return a count tensor that contains the count of each element of Unique output tensor contains all the unique elements of the input tensor
the output tensor in the input tensor. in the same order that they occur in the input tensor.
Index tensor that contains the index of each element of the input tensor in the unique output tensor.
Count tensor that contains the count of each element of the output tensor in the input tensor.
Note: Note:
Call batch op before calling this function. Call batch op before calling this function.

@ -57,7 +57,13 @@ def restricted_loads(s):
if isinstance(s, str): if isinstance(s, str):
raise TypeError("can not load pickle from unicode string") raise TypeError("can not load pickle from unicode string")
f = io.BytesIO(s) f = io.BytesIO(s)
return RestrictedUnpickler(f, encoding='bytes').load() try:
return RestrictedUnpickler(f, encoding='bytes').load()
except pickle.UnpicklingError:
raise RuntimeError("Not a valid Cifar10 Dataset.")
else:
raise RuntimeError("Unexpected error while Unpickling Cifar10 Dataset.")
class Cifar10: class Cifar10:
""" """

@ -56,7 +56,13 @@ def restricted_loads(s):
if isinstance(s, str): if isinstance(s, str):
raise TypeError("can not load pickle from unicode string") raise TypeError("can not load pickle from unicode string")
f = io.BytesIO(s) f = io.BytesIO(s)
return RestrictedUnpickler(f, encoding='bytes').load() try:
return RestrictedUnpickler(f, encoding='bytes').load()
except pickle.UnpicklingError:
raise RuntimeError("Not a valid Cifar100 Dataset.")
else:
raise RuntimeError("Unexpected error while Unpickling Cifar100 Dataset.")
class Cifar100: class Cifar100:
""" """

Loading…
Cancel
Save