Class RandomChoice

Inheritance Relationships

Base Type

Class Documentation

class RandomChoice : public mindspore::dataset::TensorTransform

Randomly select one transform from a list of transforms to perform on the input tensor.

Public Functions

explicit RandomChoice(const std::vector<TensorTransform*> &transforms)

Constructor.

Parameters

transforms[in] A vector of raw pointers to TensorTransform objects to be applied.

Example
/* Define operations */
auto resize_op(new vision::Resize({30, 30}));
auto random_crop_op(new vision::RandomCrop({28, 28}));
auto center_crop_op(new vision::CenterCrop({16, 16}));
auto random_op(new transforms::RandomChoice({resize_op, random_crop_op, center_crop_op}));

/* dataset is an instance of Dataset object */
dataset = dataset->Map({random_op},   // operations
                       {"image"});    // input columns
explicit RandomChoice(const std::vector<std::shared_ptr<TensorTransform>> &transforms)

Constructor.

Parameters

transforms[in] A vector of shared pointers to TensorTransform objects to be applied.

Example
/* Define operations */
std::shared_ptr<TensorTransform> resize_op(new vision::Resize({30, 30}));
std::shared_ptr<TensorTransform> random_crop_op(new vision::RandomCrop({28, 28}));
std::shared_ptr<TensorTransform> random_op(new transforms::RandomChoice({resize_op, random_crop_op}));

/* dataset is an instance of Dataset object */
dataset = dataset->Map({random_op},   // operations
                       {"image"});    // input columns
explicit RandomChoice(const std::vector<std::reference_wrapper<TensorTransform>> &transforms)

Constructor.

Parameters

transforms[in] A vector of TensorTransform objects to be applied.

Example
/* Define operations */
vision::Resize resize_op = vision::Resize({30, 30});
vision::RandomCrop random_crop_op = vision::RandomCrop({28, 28});
vision::CenterCrop center_crop_op = vision::CenterCrop({16, 16});
transforms::RandomChoice random_op = transforms::RandomChoice({resize_op, random_crop_op, center_crop_op});

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

Destructor.