I am trying to write a classification code for a kaggle competition. During training, it works perfectly fine but during validation, it gets stuck and shows the following error:
The size of tensor a (5) must match the size of tensor b (32) at non-singleton dimension 1
Here is my code snippet:
data= (src.transform(tfms,size=256,resize_method=ResizeMethod.SQUISH,padding_mode='zeros') #Data augmentation
.databunch(bs=32,num_workers=4) #DataBunch
.normalize(imagenet_stats) #Normalize
)
kappa = KappaScore()
kappa.weights = "quadratic"
model_name = 'efficientnet-b0'
model = EfficientNet.from_pretrained(model_name, num_classes=5)
learn = Learner(data, model, metrics = [kappa], model_dir='models')
learn.loss_fn = nn.CrossEntropyLoss()
lr = 1e-2
learn.fit_one_cycle(5, max_lr=lr)
Any sort of help would be highly appreciated.