Transfer learning with inception-v3 from torchvision

Hi,
I’m trying to train last layer of inceptionv3 model from torchvision and I’m a little bit confused (false: I’m very confused!) about the pertinence of adding or not a normalization in the transform, using or not the transform_input argument, etc etc.

For the moment my code looks like:

data_transforms = {
        'train': transforms.Compose([
            transforms.RandomSizedCrop(299),
            transforms.RandomHorizontalFlip(),
            transforms.ToTensor(),
            transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
            # should it be [0.5,0.5,0.5],[0.5,0.5,0.5]?
        ]), ...

and later

model = models.inception_v3(pretrained=True) # should I use transform_input?
model.fc = nn.Linear(2048, 4) # I have 4 classes

My results are not as good as when I use tensorflow for the transfer learning and I don’t know why.
Thanks for any help

1 Like

Here a transfer learning tutorial
http://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html#sphx-glr-beginner-transfer-learning-tutorial-py