The size of tensor must match the size of tensor b at non-singleton dimension

I want to create a segmentation network with 4 nodes at the end(x1,y1,x2,y2).
I have used L1lossfunction.
my validation set,custom head info is given below.
when i fit the model i get this error:
The size of tensor a (4) must match the size of tensor b (499) at non-singleton dimension 1

This error is occurring in my lossfunction .
i in the above error 4 in my output size, and 499 is total label’s in validation set.
i am unable to figure out what changes i should make. Please help.

f_model=models.resnet34
sz=224
bs=32

Valid: LabelList (500 items)
x: ImageList
Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224),Image (3, 224, 224)
y: MultiCategoryList
174;169;266;300,146;174;499;332,32;1;444;288,68;113;374;357,0;31;317;469

head_reg4 = nn.Sequential(Flatten(), nn.Linear(25088,4))
learn = cnn_learner(data,f_model,custom_head=head_reg4)
learn.opt_fn = optim.Adam
learn.loss_func=nn.L1Loss()

ReLU [512, 7, 7] 0 False


Conv2d [512, 7, 7] 2,359,296 False


BatchNorm2d [512, 7, 7] 1,024 True


Flatten [25088] 0 False


Linear [4] 100,356 True


Did you find out the answer? I have the same issue