mindspore.dataset.deserialize

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

Construct dataset pipeline from a JSON file produced by de.serialize().

Note

Currently Python function deserialization of map operator are not supported.

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

  • json_filepath (str) – A path to the JSON file (default=None).

Returns

de.Dataset or None if error occurs.

Raises

OSError – Can not open the JSON file.

Examples

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