I am trying to use 10-crop testing feature of Pytorch. However, i want to store the dataloader to a pickle file for efficiency. Ten crop testing requires a lambda function and i get a traceback as follows
AttributeError: Can't pickle local object 'main.<locals>.<lambda>'
So is there any other way apart from the one mentioned in original docs http://pytorch.org/docs/master/torchvision/transforms.html#torchvision.transforms.TenCrop
FYI original tencrop transform is
transform = Compose([
TenCrop(size),
Lambda(lambda crops: torch.stack([ToTensor()(crop) for crop in crops]))
])
The imagenet example is https://github.com/pytorch/examples/blob/master/imagenet/main.py
though this issue is independent of the dataset.