Metadata Function
For each sample, Tensorleap allows additional data to be added for future analysis. Each defined piece of data is wrapped in a metadata function.
from code_loader.contract.datasetclasses import PreprocessResponse
from code_loader.inner_leap_binder.leapbinder_decorators import tensorleap_custom_loss
import numpy as np
...
@tensorleap_metadata(name='metadata_label_description', metadata_type={"label":DatasetMetadataType.int, "is_circle": DatasetMetadataType.bool})
def metadata_label(idx: int, preprocess: PreprocessResponse) -> Dict[str,Union[int, bool]:
return {
'label': int_metadata_creator(preprocess, idx),
'is_circle': bool_metadata_creator(preprocess, idx),
}
The @tensorleap_metadata decorator registers each metadata function into the Tensorleap integration.
You can add additional custom metadata that will later be available for each sample to help with analysis. This function is called for each evaluated sample.
These functions should return either:
An int/bool/float/str property per sample
A dictionary with multiple attributes that maps str keys to int/bool/float/str properties
When using the dictionary syntax, the supplied dictionary must be flat (i.e. a mapping of a str to bool/float/str/int). Non-flat dictionaries will result in integration errors.
Usage within the full script can be found at the Integration Script.
Last updated
Was this helpful?