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.

Parameters

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

样例
/* 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
explicit Compose(const std::vector<std::shared_ptr<TensorTransform>> &transforms)

Constructor.

Parameters

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

样例
/* 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
explicit Compose(const std::vector<std::reference_wrapper<TensorTransform>> &transforms)

Constructor.

Parameters

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

样例
/* 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
~Compose() = default

Destructor.