Class RandomSelectSubpolicy

Inheritance Relationships

Base Type

Class Documentation

class RandomSelectSubpolicy : public mindspore::dataset::TensorTransform

Choose a random sub-policy from a list to be applied on the input image. A sub-policy is a list of tuples (operation, prob), where operation is a TensorTransform operation and prob is the probability that this operation will be applied. Once a sub-policy is selected, each operation within the sub-policy with be applied in sequence according to its probability.

Public Functions

explicit RandomSelectSubpolicy(const std::vector<std::vector<std::pair<TensorTransform*, double>>> &policy)

Constructor.

Example
/* Define operations */
auto invert_op(new vision::Invert());
auto equalize_op(new vision::Equalize());

std::vector<std::pair<TensorTransform *, double>> policy = {{invert_op, 0.5}, {equalize_op, 0.4}};
vision::RandomSelectSubpolicy random_select_subpolicy_op = vision::RandomSelectSubpolicy({policy});

/* dataset is an instance of Dataset object */
dataset = dataset->Map({random_select_subpolicy_op},    // operations
                       {"image"});                      // input columns

参数

policy[in] Vector of sub-policies to choose from, in which the TensorTransform objects are raw pointers.

explicit RandomSelectSubpolicy(const std::vector<std::vector<std::pair<std::shared_ptr<TensorTransform>, double>>> &policy)

Constructor.

Example
/* Define operations */
std::shared_ptr<TensorTransform> invert_op(new vision::Invert());
std::shared_ptr<TensorTransform> equalize_op(new vision::Equalize());
std::shared_ptr<TensorTransform> resize_op(new vision::Resize({15, 15}));

auto random_select_subpolicy_op = vision::RandomSelectSubpolicy({
                                     {{invert_op, 0.5}, {equalize_op, 0.4}},
                                     {{resize_op, 0.1}}
                                  });

/* dataset is an instance of Dataset object */
dataset = dataset->Map({random_select_subpolicy_op},    // operations
                       {"image"});                      // input columns

参数

policy[in] Vector of sub-policies to choose from, in which the TensorTransform objects are shared pointers.

explicit RandomSelectSubpolicy(const std::vector<std::vector<std::pair<std::reference_wrapper<TensorTransform>, double>>> &policy)

Constructor.

Example
/* Define operations */
vision::Invert invert_op = vision::Invert();
vision::Equalize equalize_op = vision::Equalize();
vision::Resize resize_op = vision::Resize({15, 15});

auto random_select_subpolicy_op = vision::RandomSelectSubpolicy({
                                     {{invert_op, 0.5}, {equalize_op, 0.4}},
                                     {{resize_op, 0.1}}
                                  });

/* dataset is an instance of Dataset object */
dataset = dataset->Map({random_select_subpolicy_op},    // operations
                       {"image"});                      // input columns

参数

policy[in] Vector of sub-policies to choose from, in which the TensorTransform objects are object pointers.

~RandomSelectSubpolicy() = default

Destructor.