Ground Truth Encoder

The ground truth encoder generates a ground truth value correlated with a sample, with index idx, from the preprocess. It will later be used as the ground truth for the loss function. This function is called for each evaluated sample.

For example:

from code_loader.contract.datasetclasses import PreprocessResponse
from code_loader.inner_leap_binder.leapbinder_decorators import tensorleap_gt_encoder

@tensorleap_gt_encoder(name='classes')
def gt_encoder(idx: int, preprocess: Union[PreprocessResponse, list]) -> np.ndarray:
    return preprocess.data.iloc[idx]['ground_truth'].astype('float32')

The @tensorleap_gt_encoder decorator registers each gt encoder into the Tensorleap integration.

Usage within the full script can be found at the Dataset Script.

Last updated

Was this helpful?