mindspore.dataset.deserialize

mindspore.dataset.deserialize(input_dict=None, json_filepath=None)[source]

Construct dataset pipeline from a JSON file produced by dataset serialize function.

Parameters
  • input_dict (dict) – A Python dictionary containing a serialized dataset graph. Default: None.

  • json_filepath (str) – A path to the JSON file containing dataset graph. User can obtain this file by calling API mindspore.dataset.serialize() . Default: None.

Returns

de.Dataset or None if error occurs.

Raises

OSError – Can not open the JSON file.

Examples

>>> import mindspore.dataset as ds
>>> import mindspore.dataset.transforms as transforms
>>>
>>> mnist_dataset_dir = "/path/to/mnist_dataset_directory"
>>> dataset = ds.MnistDataset(mnist_dataset_dir, num_samples=100)
>>> one_hot_encode = transforms.OneHot(10)  # num_classes is input argument
>>> dataset = dataset.map(operations=one_hot_encode, input_columns="label")
>>> dataset = dataset.batch(batch_size=10, drop_remainder=True)
>>>
>>> # Case 1: to/from JSON file
>>> serialized_data = ds.serialize(dataset, json_filepath="/path/to/mnist_dataset_pipeline.json")
>>> deserialized_dataset = ds.deserialize(json_filepath="/path/to/mnist_dataset_pipeline.json")
>>>
>>> # Case 2: to/from Python dictionary
>>> serialized_data = ds.serialize(dataset)
>>> deserialized_dataset = ds.deserialize(input_dict=serialized_data)