Tensor Utilities

Dictionary-of-tensors stack / concat / split utilities used by the logger.

myosuite.utils.tensor_utils.stack_tensor_dict_list(tensor_dict_list)

Stack a list of dicts of arrays into a dict of stacked arrays.

Parameters:

tensor_dict_list (list[dict]) – Non-empty list of dicts with identical key sets. Values may be arrays or nested dicts.

Return type:

dict

Returns:

A dict with the same keys; each value is the result of np.array([x[k] for x in tensor_dict_list]).

myosuite.utils.tensor_utils.concat_tensor_dict_list(tensor_dict_list)

Concatenate a list of dicts of arrays along axis 0.

Parameters:

tensor_dict_list (list[dict]) – Non-empty list of dicts with identical key sets.

Return type:

dict

Returns:

A dict where each value is np.concatenate([x[k] ...], axis=0).

myosuite.utils.tensor_utils.split_tensor_dict_list(tensor_dict)

Inverse of stack_tensor_dict_list().

Splits a dict of arrays (first axis = time/batch) into a list of single-step dicts.

Parameters:

tensor_dict (dict) – Dict whose values are arrays or nested dicts.

Return type:

list[dict]

Returns:

A list of dicts, one per element along the first axis.