mindspore.dataset.vision.c_transforms.RandomSelectSubpolicy

class mindspore.dataset.vision.c_transforms.RandomSelectSubpolicy(policy)[source]

Choose a random sub-policy from a policy list to be applied on the input image.

Parameters

policy (list(list(tuple(TensorOp, prob (float)))) – List of sub-policies to choose from. A sub-policy is a list of tuples (op, prob), where op is a TensorOp operation and prob is the probability that this op will be applied, and the prob values must be in range [0, 1]. Once a sub-policy is selected, each op within the sub-policy with be applied in sequence according to its probability.

Examples

>>> policy = [[(c_vision.RandomRotation((45, 45)), 0.5),
...            (c_vision.RandomVerticalFlip(), 1),
...            (c_vision.RandomColorAdjust(), 0.8)],
...           [(c_vision.RandomRotation((90, 90)), 1),
...            (c_vision.RandomColorAdjust(), 0.2)]]
>>> image_folder_dataset = image_folder_dataset.map(operations=c_vision.RandomSelectSubpolicy(policy),
...                                                 input_columns=["image"])