Interfaces

Functionality

public encodefunction

encode(method, context, sample) -> (x, y)
encode(method, context, (input, target)) -> (x, y)

Encode a sample containing both input and target.

If sample is a Tuple of (input, target), the default behavior is to pass them to encodeinput and encodetarget.

Remarks

  • When should I implement encode vs. encodeinput and encodetarget?

    In simple cases like image classification we can encode the inputs and targets separately and you should prefer encodeinput and encodetarget. The default implementation for encode when given an (input, target)-tuple is to delegate to encodeinput and encodetarget.

    In other cases like semantic segmentation, however, we want to apply stochastic augmentations to both image and segmentation mask. In that case you need to encode both at the same time using encode.

    Another situation where encode is needed is when sample is not a tuple of (input, target), for example a Dict that includes additional information. encode still needs to return an (x, y)-tuple, though.