-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" | ||
""" | ||
|
||
# Created by Wenjie Du <[email protected]> | ||
# License: BSD-3-Clause | ||
|
||
|
||
from .metric import BaseMetric | ||
from ..functional import calc_mse | ||
|
||
|
||
class BaseLoss(BaseMetric): | ||
def __init__( | ||
self, | ||
): | ||
super().__init__() | ||
|
||
def forward(self, prediction, target): | ||
raise NotImplementedError | ||
|
||
|
||
class MAE_Loss(BaseLoss): | ||
def __init__(self): | ||
super().__init__() | ||
|
||
def forward(self, prediction, target, mask=None): | ||
return calc_mse(prediction, target, mask) |
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,29 @@ | ||
""" | ||
""" | ||
|
||
# Created by Wenjie Du <[email protected]> | ||
# License: BSD-3-Clause | ||
|
||
|
||
import torch.nn as nn | ||
|
||
from ..functional import calc_pr_auc | ||
|
||
|
||
class BaseMetric(nn.Module): | ||
def __init__(self, lower_better: bool = True): | ||
super().__init__() | ||
self.lower_better = lower_better | ||
|
||
def forward(self, prediction, target): | ||
raise NotImplementedError | ||
|
||
|
||
class PR_AUC(BaseMetric): | ||
def __init__(self): | ||
super().__init__(lower_better=False) | ||
|
||
def forward(self, prediction, target): | ||
pr_auc, _, _, _ = calc_pr_auc(prediction, target) | ||
return pr_auc |