|
1 | 1 | import numpy as np |
2 | | -from tqdm import tqdm |
| 2 | +from tqdm.notebook import tqdm |
3 | 3 | from sklearn.metrics import roc_curve, roc_auc_score, precision_recall_curve, auc |
4 | 4 | from utils import * |
| 5 | +import argparse |
| 6 | +import torch |
| 7 | +import torch.nn as nn |
| 8 | +import torchvision |
| 9 | +import torchvision.transforms as transforms |
| 10 | +from torch.utils.data import DataLoader |
| 11 | +from sklearn.mixture import GaussianMixture |
| 12 | +import numpy as np |
| 13 | +from scipy.stats import multivariate_normal |
| 14 | +from sklearn.covariance import EmpiricalCovariance |
| 15 | +from robustbench.utils import load_model |
| 16 | +import torch.nn.functional as F |
| 17 | +from torch.utils.data import TensorDataset |
| 18 | +from torch.optim.lr_scheduler import StepLR |
| 19 | +from tqdm.notebook import tqdm |
| 20 | + |
| 21 | + |
5 | 22 | def compute_fpr95(labels, scores): |
6 | 23 |
|
7 | 24 | fpr, tpr, thresholds = roc_curve(labels, scores) |
@@ -60,9 +77,9 @@ def get_clean_AUC(model, test_loader , device, num_classes): |
60 | 77 | auroc = compute_auroc(test_labels, anomaly_scores) |
61 | 78 | aupr = compute_aupr(test_labels, anomaly_scores) |
62 | 79 |
|
63 | | - # print(f"FPR95: {fpr95}") |
| 80 | + print(f"FPR95: {fpr95}") |
64 | 81 | print(f"AUROC is: {auroc}") |
65 | | - # print(f"AUPR: {aupr}") |
| 82 | + print(f"AUPR: {aupr}") |
66 | 83 |
|
67 | 84 | return auc |
68 | 85 |
|
@@ -598,9 +615,9 @@ def get_auc_adversarial(model, test_loader, test_attack, device, num_classes): |
598 | 615 | auroc = compute_auroc(test_labels, anomaly_scores) |
599 | 616 | aupr = compute_aupr(test_labels, anomaly_scores) |
600 | 617 |
|
601 | | - # print(f"FPR95: {fpr95}") |
| 618 | + print(f"FPR95: {fpr95}") |
602 | 619 | print(f"AUROC is: {auroc}") |
603 | | - # print(f"AUPR: {aupr}") |
| 620 | + print(f"AUPR: {aupr}") |
604 | 621 |
|
605 | 622 |
|
606 | 623 | if is_train: |
|
0 commit comments