avalanche-transformations
Dealing with transformations (groups, appending, replacing, freezing).
!pip install avalanche-libTransformation groups
from torchvision import transforms
from torchvision.datasets import MNIST
from avalanche.benchmarks.utils import make_classification_dataset
mnist_dataset = MNIST('mnist_data', download=True)
# Define the training transformation for X values
train_transformation = transforms.Compose([
transforms.RandomRotation(45),
transforms.ToTensor(),
])
# Define the training transformation for Y values (rarely used)
train_target_transformation = None
# Define the test transformation for X values
eval_transformation = transforms.ToTensor()
# Define the test transformation for Y values (rarely used)
eval_target_transformation = None
transform_groups = {
'train': (train_transformation, train_target_transformation),
'eval': (eval_transformation, eval_target_transformation)
}
avl_mnist_transform = make_classification_dataset(mnist_dataset, transform_groups=transform_groups)Using .train() and .eval()
.train() and .eval()Custom transformation groups
Replacing transformations
Freezing transformations
Transformations wrap-up
🤝 Run it on Google Colab
Was this helpful?