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
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)