Hi John1231983,
Apologies. My intention was to help you optimize the loss function and generalize it to 5d tensors.
In general, if you have a 5d tensor [N, C, H, W, D], you should utilize the information available due the fifth dimension.
You could of course reshape your tensor to [N*C, H, W, D] using .view(N * C, H, W, D). However, it may give rise to unwanted effects.
For example, in applying a weighted cross entropy loss for medical mri scans for brain tumor segmentation, per patient weight and per slice weight could give very different losses.
Hope this helps!