-
Notifications
You must be signed in to change notification settings - Fork 6
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
13 changed files
with
210 additions
and
258 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
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,6 @@ | ||
import torch.nn as nn | ||
|
||
|
||
def get_criterion(pred, target): | ||
loss = nn.BCEWithLogitsLoss(reduction="none") | ||
return loss(pred, target) |
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,9 @@ | ||
import numpy as np | ||
from sklearn.metrics import accuracy_score, roc_auc_score | ||
|
||
|
||
def get_metric(targets, preds): | ||
auc = roc_auc_score(targets, preds) | ||
acc = accuracy_score(targets, np.where(preds >= 0.5, 1, 0)) | ||
|
||
return auc, acc |
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,13 @@ | ||
from torch.optim import Adam, AdamW | ||
|
||
|
||
def get_optimizer(model, args): | ||
if args.optimizer == "adam": | ||
optimizer = Adam(model.parameters(), lr=args.lr, weight_decay=0.01) | ||
if args.optimizer == "adamW": | ||
optimizer = AdamW(model.parameters(), lr=args.lr, weight_decay=0.01) | ||
|
||
# 모든 parameter들의 grad값을 0으로 초기화 | ||
optimizer.zero_grad() | ||
|
||
return optimizer |
Oops, something went wrong.