Skip to content

AsDiscrete needs to add channel dim for scalar label values #2554

@Nic-Ma

Description

@Nic-Ma

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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions