I’m using a pre-trained Resnet model torchvision.models.resnet18(pretrained=True) to classify flower images, the dataset contains 112 classes and I’m iterating over the DataLoader image by image:
for count, (image, label) in enumerate(train):
    print(image.size(), type(image), label.size(), type(label))  # torch.Size([1, 3, 224, 224]) <class 'torch.Tensor'> torch.Size([1]) <class 'torch.Tensor'>

When I calculate the loss criterion(output.float(), label.float()) I receive the following error:
RuntimeError: input and target shapes do not match: input [1 x 1000], target [1] at /opt/conda/conda-bld/pytorch_1533672544752/work/aten/src/THNN/generic/MSECriterion.c:12

How can I fix this error and still using the pre-trained model ? (the optimizer is ADAM and the loss function is MSELoss)