Class RandomApply
Defined in File transforms.h
Inheritance Relationships
Base Type
public mindspore::dataset::TensorTransform
(Class TensorTransform)
Class Documentation
-
class RandomApply : public mindspore::dataset::TensorTransform
Randomly perform a series of transforms with a given probability.
Public Functions
-
explicit RandomApply(const std::vector<TensorTransform*> &transforms, double prob = 0.5)
Constructor.
- Parameters
transforms – [in] A vector of raw pointers to TensorTransform objects to be applied.
prob – [in] The probability to apply the transformation list (default=0.5).
样例/* 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::RandomApply({resize_op, random_crop_op, center_crop_op})); /* dataset is an instance of Dataset object */ dataset = dataset->Map({random_op}, // operations {"image"}); // input columns
Constructor.
- Parameters
transforms – [in] A vector of shared pointers to TensorTransform objects to be applied.
prob – [in] The probability to apply the transformation list (default=0.5).
样例/* 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::RandomApply({resize_op, random_crop_op})); /* dataset is an instance of Dataset object */ dataset = dataset->Map({random_op}, // operations {"image"}); // input columns
-
explicit RandomApply(const std::vector<std::reference_wrapper<TensorTransform>> &transforms, double prob = 0.5)
Constructor.
- Parameters
transforms – [in] A vector of TensorTransform objects to be applied.
prob – [in] The probability to apply the transformation list (default=0.5).
样例/* 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::RandomApply random_op = transforms::RandomApply({resize_op, random_crop_op, center_crop_op}); /* dataset is an instance of Dataset object */ dataset = dataset->Map({random_op}, // operations {"image"}); // input columns
-
~RandomApply() = default
Destructor.
-
explicit RandomApply(const std::vector<TensorTransform*> &transforms, double prob = 0.5)