MCPcopy Create free account
hub / github.com/tensorflow/datasets / read_d4rl_dataset

Function read_d4rl_dataset

tensorflow_datasets/d4rl/dataset_utils.py:260–272  ·  view source on GitHub ↗

Reads a D4RL dataset and returns the dataset as a dictionary.

(file_path: str)

Source from the content-addressed store, hash-verified

258
259
260def read_d4rl_dataset(file_path: str):
261 """Reads a D4RL dataset and returns the dataset as a dictionary."""
262 with tf.io.gfile.GFile(file_path, 'rb') as f:
263 with h5py.File(f, 'r') as dataset_file:
264 dataset_dict = {}
265 for k in _get_dataset_keys(dataset_file):
266 try:
267 # first try loading as an array
268 dataset_dict[k] = dataset_file[k][:]
269 except ValueError: # try loading as a scalar
270 dataset_dict[k] = dataset_file[k][()]
271
272 return dataset_dict

Callers 1

generate_examplesFunction · 0.85

Calls 1

_get_dataset_keysFunction · 0.85

Tested by

no test coverage detected