-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- using EpochMetric for calculating validation loss after every epoch - transforms - scaling intensity - randomly scaling intensity while training - thresholding net outputs and keeping largest island only
- Loading branch information
Showing
2 changed files
with
162 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import torch | ||
|
||
from monai.handlers.iteration_metric import IterationMetric | ||
|
||
|
||
class LossMetric(IterationMetric): | ||
|
||
def __init__( | ||
self, | ||
metric_fn, | ||
output_transform=lambda x: x, | ||
device="cpu", | ||
save_details=True, | ||
): | ||
super().__init__( | ||
metric_fn=metric_fn, | ||
output_transform=output_transform, | ||
device=device, | ||
save_details=save_details, | ||
) | ||
|
||
def compute(self): | ||
return torch.Tensor(self._scores).mean() |