transform
, which is applied to X values, and the target_transform
, which is applied to Y values. The latter is rarely used. This means that a transformation group is a pair of transformations to be applied to the X and Y values of each instance returned by the dataset. In both torchvision and Avalanche implementations, a transformation must be a function (or other callable object) that accepts one input (the X or Y value) and outputs its transformed version. This pair of functions is stored in the transform
and target_transform
fields of the dataset. A comprehensive guide on transformations can be found in the torchvision documentation.transform
and target_transform
constructor parameters to set the transformations for both the train and the eval groups. However, it is recommended to use the approach based on transform_groups (shown in the code above) as it is much more flexible..train()
and .eval()
transform
and target_transform
fields. These fields can be changed directly, but this is NOT recommended, as this will not create a copy of the dataset and may probably affect other parts of the code in which the dataset is used..train()
and .eval()
methods to obtain a copy (view) of the dataset with the proper transformations enabled. This is another very handy feature of the AvalancheDataset: methods that manipulate the AvalancheDataset fields (and transformations) always create a view of the dataset. The original dataset is never changed..train()
and .eval()
never change the group of the dataset on which they are called: they always create a view.initial_transform_group
constructor parameter.with_transforms(group_name)
method.with_transforms(group_name)
method behaves in the same way .train()
and .eval()
do by creating a view of the original dataset.None
, then Compose
will not complain, but the process will crash later (try it by yourself: replace the first element of Compose in cell above with None
, then try obtaining a data point from the dataset)..add_transforms(transform=None, target_transform=None)
method will append the given transform(s) to the currently enabled transform group and will return a new (a view actually) dataset with given transformations appended to the existing ones. The original dataset is not affected. One can also use .add_transforms_to_group(group_name, transform, target_transform)
to change transformations for a different group..add_transforms(...)
to append the to_append_transform transform defined in the cell above..add_transforms(...)
:.replace_transforms(transform, target_transform)
one can obtain a view of the original dataset in which the transformaations for the current group are replaced with the given ones. One may also change tranformations for other groups by passing the name of the group as the optional parameter group
. As with any transform-related operation, the original dataset is not affected..replace_transforms(...)
to remove previous transformations (by passing None
as the new transform)..replace_transforms(...)
to replace the transformations of the current group:.replace_transforms(...)
or even by changing the transform
field directly..freeze_transforms()
. Transformations can be frozen for a single group by using .freeze_group_transforms(group_name)
. As always, those methods return a view of the original dataset..freeze_transforms()
.replace_transforms
can't remove frozen transformations: