mindspore.dataset.transforms.Fill
- class mindspore.dataset.transforms.Fill(fill_value)[source]
Tensor operation to fill all elements in the tensor with the specified value. The output tensor will have the same shape and type as the input tensor.
- Parameters
fill_value (Union[str, bytes, int, float, bool]) – scalar value to fill the tensor with.
- Raises
TypeError – If fill_value is not of type str, float, bool, int or bytes.
- Supported Platforms:
CPU
Examples
>>> import mindspore.dataset as ds >>> import mindspore.dataset.transforms as transforms >>> import numpy as np >>> >>> # generate a 1D integer numpy array from 0 to 4 >>> def generator_1d(): ... for i in range(5): ... yield (np.array([i]),) >>> generator_dataset = ds.GeneratorDataset(generator_1d, column_names="col1") >>> # [[0], [1], [2], [3], [4]] >>> fill_op = transforms.Fill(3) >>> generator_dataset = generator_dataset.map(operations=fill_op) >>> # [[3], [3], [3], [3], [3]]