mindspore.dataset.vision.write_file
- mindspore.dataset.vision.write_file(filename, data)[source]
Write the one dimension uint8 data into a file using binary mode.
- Parameters
filename (str) – The path to the file to be written.
data (Union[numpy.ndarray, mindspore.Tensor]) – The one dimension uint8 data to be written.
- Raises
TypeError – If filename is not of type str.
TypeError – If data is not of type numpy.ndarray or mindspore.Tensor.
RuntimeError – If the filename is not a common file.
RuntimeError – If the data type of data is not uint8.
RuntimeError – If the shape of data is not a one-dimensional array.
- Supported Platforms:
CPU
Examples
>>> import mindspore.dataset.vision as vision >>> import numpy as np >>> # Generate a random data with 1024 bytes >>> data = np.random.randint(256, size=(1024), dtype=np.uint8) >>> vision.write_file("/path/to/file", data)