-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update loss.py * fixing default * trying to have good default values * fixing stuff * removing useless logic
- Loading branch information
Showing
4 changed files
with
8 additions
and
13 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
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 |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import numpy as np | ||
from sklearn.metrics import accuracy_score | ||
|
||
|
||
def metric(y_true, y_pred): | ||
y_true = y_true.astype("uint8") | ||
# The try except is needed because when the metric is batched some batches | ||
# have one class only | ||
try: | ||
# return roc_auc_score(y_true, y_pred) | ||
# proposed modification in order to get a metric that calcs on center 2 | ||
# (y=1 only on that center) | ||
return ((y_pred > 0.5) == y_true).mean() | ||
except ValueError: | ||
return np.nan | ||
y_pred = np.argmax(y_pred, axis=1) | ||
return accuracy_score(y_true, y_pred) | ||
|
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