Class ToNumber

Inheritance Relationships

Base Type

Class Documentation

class ToNumber : public mindspore::dataset::TensorTransform

Convert every element in a string tensor to a number. Strings are cast according to the rules specified in the following links: https://en.cppreference.com/w/cpp/string/basic_string/stof, https://en.cppreference.com/w/cpp/string/basic_string/stoul, except that any strings which represent negative numbers cannot be cast to an unsigned integer type.

Public Functions

explicit ToNumber(mindspore::DataType data_type)

Constructor.

Parameters

data_type[in] mindspore::DataType of the tensor to be cast to. Must be a numeric type, excluding bool.

样例
/* Define operations */
auto to_number_op = text::ToNumber(mindspore::DataType::kNumberTypeInt8);

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

Destructor.