public encode — function
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
encodevs.encodeinputandencodetarget?In simple cases like image classification we can encode the inputs and targets separately and you should prefer
encodeinputandencodetarget. The default implementation forencodewhen given an(input, target)-tuple is to delegate toencodeinputandencodetarget.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
encodeis needed is whensampleis not a tuple of(input, target), for example aDictthat includes additional information.encodestill needs to return an(x, y)-tuple, though.