lidaryani:

so I doubted the size of the target and model.


Which size did you double? The spatial size or the number of channels?
If you are using another loss function, e.g. dice loss, you have to make sure to pass the output and target in a specific shape. Have a look at this post 12 to see an implementation of multi-class dice loss.