noether.data.pipeline.batch_processors.rename_keys

Classes

RenameKeysBatchProcessor

Utility processor that simply renames the dictionary keys in a batch.

Module Contents

class noether.data.pipeline.batch_processors.rename_keys.RenameKeysBatchProcessor(key_map)

Bases: noether.data.pipeline.batch_processor.BatchProcessor

Utility processor that simply renames the dictionary keys in a batch. Rename keys in the batch if they are in the key_map and keep old keys otherwise. Creates a new dictionary whose keys are renamed but uses references to the values of the old dict. This avoids copying the data and at the same time does not modify this function’s input.

Parameters:

key_map (dict[str, str]) – dict with source keys as keys and target keys as values. The source keys are renamed target keys.

key_map
denormalize(key, value)

Inverts the key mapping from the __call__ method.

Parameters:
  • key (str) – The name of the item.

  • value (torch.Tensor) – The value of the item.

Returns:

The (potentially) remapped name and the unchanged value.

Return type:

(key, value)