I faced this error when I tried to train model with large dataset (as I tested it with a few subset and works fine). I added “drop_last=True” to avoid the division problem by the batch size.
Any idea about the error I faced : “The size of tensor a (0) must match the size of tensor b (4) at non-singleton dimension 1”
Based on the error message it seems boxes is an empty tensor:
boxes = torch.tensor([])
boxes + torch.tensor([0., 1., 2., 3.])
# RuntimeError: The size of tensor a (0) must match the size of tensor b (4) at non-singleton dimension 0
so make sure this tensor is valid before trying to add another tensor to it.