Reads a D4RL dataset and returns the dataset as a dictionary.
(file_path: str)
| 258 | |
| 259 | |
| 260 | def 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 |
no test coverage detected