I guess you simply have an issue about dimensionality.
Check this example:
import torch

my_loss=torch.nn.L1Loss()

a1=torch.rand(1,10)

a2 = torch.rand(10)

my_loss(a1,a2)
Traceback (most recent cal
RuntimeError: input and target shapes do not match: input [1 x 10], target [10] at /pytorch/aten/src/THNN/generic/AbsCriterion.c:12

Both are a tensor of 10 elements. However, a1 is of size 1x10 meanwhile a2 is of size 10.
PyTorch usually assign an additional dimension for the batch. That’s why your output is 1x102 and not just 102.
However, ground-truth is handled by you. If you don’t assign (unsqueeze) your ground-truth to match the outgoing dimensionality it will throw the error you saw.