Commit 5ebcade
Fix incomplete activation validation in HausdorffDTLoss (Project-MONAI#8841)
The validation check for mutually exclusive activation options was
incomplete - it only checked sigmoid and softmax but not other_act,
despite the error message explicitly mentioning other_act.
Without this check, passing e.g. `sigmoid=True, other_act=relu` silently
stacks both activations in `forward()` (`other_act(sigmoid(x))`) instead
of applying only one, producing an incorrect loss with no warning.
Before:
```python
if int(sigmoid) + int(softmax) > 1:
raise ValueError("... [sigmoid=True, softmax=True, other_act is not None].")
```
After:
```python
if int(sigmoid) + int(softmax) + int(other_act is not None) > 1:
raise ValueError("... [sigmoid=True, softmax=True, other_act is not None].")
```
This is consistent with the validation in dice.py and tversky.py which
correctly include all three options in the check.
Added tests for:
- sigmoid=True with other_act
- softmax=True with other_act
- All three options combined
### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
Signed-off-by: Soumya Snigdha Kundu <soumya_snigdha.kundu@kcl.ac.uk>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>1 parent c95d9a9 commit 5ebcade
2 files changed
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
215 | 221 | | |
216 | 222 | | |
217 | 223 | | |
| |||
244 | 250 | | |
245 | 251 | | |
246 | 252 | | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
247 | 259 | | |
248 | 260 | | |
249 | 261 | | |
| |||
0 commit comments