Here’s my code
Have no idea what the error is!
It just gets stuck here
################### Used to transform the data before feeding it into the neural network ##################
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(224),
                transforms.ToTensor(),
                transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
        ]),
}
############################################################################################################



if __name__ == '__main__':
	
	##### import the VGG11 pre trained model #########################################################
	#model_ft = models.vgg11(pretrained=True)
	model_ft = models.resnet18(pretrained=True)
	###### freeze all the layers in the network ######################################## 
	for param in model_ft.parameters():
		param.requires_grad = False
	#### last layer created require gradient is True by default #########################
	#model_ft.classifier._modules['6'] = nn.Linear(4096,3)

	num_ftrs = model_ft.fc.in_features
	model_ft.fc = nn.Linear(num_ftrs,3)

	model_ft = model_ft.to(device)

	criterion = nn.CrossEntropyLoss()

	optimizer_ft = optim.SGD(model_ft.fc.parameters(),lr=0.001,momentum=0.9)

	exp_lr_scheduler = lr_scheduler.StepLR(optimizer_ft,step_size=6,gamma=0.1)

	model_ft = train_model(model_ft,criterion,optimizer_ft,exp_lr_scheduler,num_epochs=6)


Epoch 0/5
train Loss: 1.0191 Acc: 0.5015
Traceback (most recent call last):
File “demotest1.py”, line 218, in 
model_ft = train_model(model_ft,criterion,optimizer_ft,exp_lr_scheduler,num_epochs=6)
File “demotest1.py”, line 119, in train_model
for i, (inputs,labels) in enumerate(dataloaders[phase]):
File “/home/ffffff/.virtualenvs/LearnPytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 336, in next
return self._process_next_batch(batch)
File “/home/ffffff/.virtualenvs/LearnPytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 357, in _process_next_batch
raise batch.exc_type(batch.exc_msg)
RuntimeError: Traceback (most recent call last):
File “/home/ffffff/.virtualenvs/LearnPytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 106, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File “/home/ffffff/.virtualenvs/LearnPytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 187, in default_collate
return [default_collate(samples) for samples in transposed]
File “/home/ffffff/.virtualenvs/LearnPytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 187, in 
return [default_collate(samples) for samples in transposed]
File “/home/ffffff/.virtualenvs/LearnPytorch/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 164, in default_collate
return torch.stack(batch, 0, out=out)
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 299 and 284 in dimension 3 at /pytorch/aten/src/TH/generic/THTensorMath.cpp:3616