mindspore.dataset.transforms.py_transforms.OneHotOp
- class mindspore.dataset.transforms.py_transforms.OneHotOp(num_classes, smoothing_rate=0.0)[source]
Apply one hot encoding transformation to the input label, make label be more smoothing and continuous.
- Parameters
- Raises
TypeError – num_classes is not of type int.
TypeError – smoothing_rate is not of type float.
ValueError – smoothing_rate is not in range [0.0, 1.0].
- Supported Platforms:
CPU
Examples
>>> # Assume that dataset has 10 classes, thus the label ranges from 0 to 9 >>> transforms_list = [py_transforms.OneHotOp(num_classes=10, smoothing_rate=0.1)] >>> transform = py_transforms.Compose(transforms_list) >>> mnist_dataset = mnist_dataset.map(input_columns=["label"], operations=transform)