Reputation: 15
I`m studying about transfer learning with the pytorch tutorial. I found pytorch tutorial author uses the different approach to train set and validation set.
data_transforms = {
'train': transforms.Compose([
transforms.RandomResizedCrop(224),
transforms.RandomHorizontalFlip(),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
]),
'val': transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
]),
}
As above, training session uses the Randomly cropped image on training. But I found that after that transformation, some of the images are totally cut off the target object and remains no useful feature for detection. I am curious why the author has chosen that method, even if it is more difficult to define different pipeline to train&validation dataset. Is there any benefit of the random cropping?
Upvotes: 1
Views: 1358
Reputation: 854
Couple of ideas behind random cropping:
In short:
More detail:
The semantics of the image are preserved but the activation values of the conv net are different. The conv net learns to associate a broader range of spatial activations with a certain class label and improves the robustness of the feature detectors in conv nets.
Look at this excerpt https://link.springer.com/chapter/10.1007/978-3-319-31293-4_25
Upvotes: 3