The stacktrace from the error points to the forward method of the fpn/decoder (not the loss function) and explains that the skip connection is failing with a shape mismatch in dim3 which should be a spatial size. These errors are usually raised if your model isn’t flexible enough to accept different spatial input shapes and depends on e.g. powers of two (or other commonly used shapes such as 224x224).