Class ToTensor

Inheritance Relationships

Base Type

Class Documentation

class ToTensor : public mindspore::dataset::TensorTransform

Divide the pixel values by 255 and convert from HWC format to CHW format with required datatype.

Public Functions

ToTensor()

Constructor.

Parameters

output_type[in] The type of the output tensor of type mindspore::DataType or String (default=mindspore::DataType::kNumberTypeFloat32).

Example
/* Define operations */
auto to_tensor_op = vision::ToTensor();

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

Destructor.