Skip to content

declearn.dataset.load_dataset_from_json

Instantiate a dataset based on a JSON dump file.

Parameters:

Name Type Description Default
path str

Path to a JSON file output by the save_to_json method of the Dataset that is being reloaded. The actual type of dataset should be specified under the "name" field of that file.

required

Returns:

Name Type Description
dataset Dataset

Dataset (subclass) instance, reloaded from JSON.

Source code in declearn/dataset/_base.py
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
def load_dataset_from_json(path: str) -> Dataset:
    """Instantiate a dataset based on a JSON dump file.

    Parameters
    ----------
    path: str
        Path to a JSON file output by the `save_to_json`
        method of the Dataset that is being reloaded.
        The actual type of dataset should be specified
        under the "name" field of that file.

    Returns
    -------
    dataset: Dataset
        Dataset (subclass) instance, reloaded from JSON.
    """
    dump = json_load(path)
    cls = access_registered(dump["name"], group="Dataset")
    return cls.load_from_json(path)