noether.data.pipeline.sample_processors.replace_key¶
Classes¶
Sample processor that replaces the key with multiple other keys. |
Module Contents¶
- class noether.data.pipeline.sample_processors.replace_key.ReplaceKeySampleProcessor(source_key, target_keys)¶
Bases:
noether.data.pipeline.sample_processor.SampleProcessorSample processor that replaces the key with multiple other keys.
Replaces a key in the batch with one or multiple other keys. Creates a new dictionary whose keys are duplicated 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.
# dummy example processor = ReplaceKeySampleProcessor(source_key="source", target_keys={"target1", "target2"}) input_sample = { "source": some_tensor, "unchanged_key": some_other_tensor, } output_sample = processor(input_sample) # output_sample will be: { # 'target1': some_tensor, # 'target2': some_tensor, # 'unchanged_key': some_other_tensor, # }
- Parameters:
- source_key¶
- target_keys¶