3694 loss function as cumulative metric#5513
Conversation
|
Hi @wyli , Users can use the ignite metric directly: Thanks. |
|
@Nic-Ma yes I'm aware of that, the assumptions on loss_fn is stronger there: -- requiring both y_pred and y, and -- the output must be a single value and --must be used with an ignite engine... In our case, previously I thought the cumulative average is good enough, MONAI/monai/metrics/cumulative_average.py Line 21 in 89684d6 But it doesn't seem to work with IgniteMetric handler. |
myron
left a comment
There was a problem hiding this comment.
assumptions on loss_fn is stronger there: -- requiring both y_pred and y, and -- the output must be a single value and --must be used with an ignite engine...
@wyli thanks for the PR , but I don't think this is what people are asking for in the issue #3694, they did not ask for Ignite support. (unless I misunderstand).
And currently we can currently use
ac = CumulativeAverage()
loss_value = someloss(x,y)
ac.append(ac)
this will work even if loss_value is an array/list/tensor (and removes nans). I'll clarify what people in the issue are actually asking, unless this PR addresses something else
|
Hi @Nic-Ma do you have any further comments here? |
OK, that makes sense. Thanks. |
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
Signed-off-by: Wenqi Li <[email protected]>
a08e06a to
ac72a8a
Compare
thank you for the reply. In the PR description on the top , it says that it fixes #3694 |
|
/build |
|
/build |
Signed-off-by: Wenqi Li <[email protected]> Fixes Project-MONAI#3694 ### Description adds a wrapper for loss function: ```py dice_loss = DiceLoss(include_background=True) loss_metric = LossMetric(loss_fn=dice_loss) ``` so that `loss_metric` it can be used as a metric in: https://github.com/Project-MONAI/MONAI/blob/b030839e98e6a00c1ab0e53545f60b62dc4da4a4/monai/handlers/ignite_metric.py#L32 ### 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). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [x] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [x] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [x] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: Wenqi Li <[email protected]> Signed-off-by: Behrooz <[email protected]>
Signed-off-by: Wenqi Li [email protected]
Fixes #3694
Description
adds a wrapper for loss function:
so that
loss_metricit can be used as a metric in:MONAI/monai/handlers/ignite_metric.py
Line 32 in b030839
Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.