Class Compose

Inheritance Relationships

Base Type

Class Documentation

class Compose : public mindspore::dataset::TensorTransform

Compose a list of transforms into a single transform.

Public Functions

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

Constructor.

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 compose_op(new transforms::Compose({resize_op, random_crop_op, center_crop_op}));

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

Parameters

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

explicit Compose(const std::vector<std::shared_ptr<TensorTransform>> &transforms)

Constructor.

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> compose_op(new transforms::Compose({resize_op, random_crop_op}));

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

Parameters

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

explicit Compose(const std::vector<std::reference_wrapper<TensorTransform>> &transforms)

Constructor.

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::Compose compose_op = transforms::Compose({resize_op, random_crop_op, center_crop_op});

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

Parameters

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

~Compose() = default

Destructor.