-
Notifications
You must be signed in to change notification settings - Fork 1.5k
AsDiscrete needs to add channel dim for scalar label values #2554
Description
Is your feature request related to a problem? Please describe.
An question raised from the internal team:
Some PyTorch loss functions (like torch.nn.CrossEntropyLoss) require the label data has no channel dim, but postprocessing transforms and metrics require the label data with channel dim if multiple-classes. Need to add channel dim in post processing if ndim=0.
Actually, we had such feature in previous versions:
https://github.com/Project-MONAI/MONAI/blob/0.5.3/monai/transforms/post/array.py#L95
VoteEnsemble already considers the no-channel data:
https://github.com/Project-MONAI/MONAI/blob/0.6.0rc2/monai/transforms/post/array.py#L413
I think maybe we deleted it by mistake when developing the decollate batch.