dict_util

aitoolbox.utils.dict_util.combine_prediction_metadata_batches(metadata_list)[source]
Combines a list of dicts with the same keys and [lists or torch.Tensors or np.arrays] as values into

a single dict with concatenated [lists or torch.Tensors or np.arrays] for each corresponding key

Parameters:

metadata_list (list) – list of dicts with matching keys and [lists or torch.Tensors or np.arrays] for values

Returns:

combined single dict

Return type:

dict

aitoolbox.utils.dict_util.flatten_dict(nested_dict, parent_key='', sep='_')[source]

Flatten the nested dict of dicts of …

Parameters:
  • nested_dict (dict) – input dict

  • parent_key (str) –

  • sep (str) – separator when flattening the category

Returns:

flattened dict

Return type:

dict

aitoolbox.utils.dict_util.combine_dict_elements(list_of_dicts)[source]

Combine into single list the elements with the same key across several dicts

Parameters:

list_of_dicts (list) – list of dicts with matching keys

Returns:

combined single dict

Return type:

dict

aitoolbox.utils.dict_util.flatten_combine_dict(train_history)[source]

Flatten all dict of dicts and combine elements with the same key into a single list in the dict

Parameters:

train_history (dict) –

Return type:

dict