-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.py
148 lines (139 loc) Β· 5.49 KB
/
log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import wandb
def wandb_log_train_only(train_loss, train_acc):
wandb.log(
{
"train_loss": train_loss,
"train_accuracy": train_acc,
}
)
def wandb_log(
project_type,
train_loss,
train_acc,
val_loss,
val_acc,
best_val_loss,
best_val_acc,
pill_type,
accuracy_by_label,
custom_label=False,
):
"""
if args.wanted_label_to_record == []:
for i in range(len(pill_type)):
wandb.log({f"{pill_type[i]}": accuracy_by_label[i]})
else:
for i in range(len(args.wanted_label_to_record)):
wandb.log({f"{pill_type[args.wanted_label_to_record[i]]}": accuracy_by_label[args.wanted_label_to_record[i]]})
μ΄λ κ² μ¬μ©ν κ²½μ°, logκ° 1λ§λ€ μ°νλκ² μλκ² λμ΄μ μλνκ° νλ¬
"""
if project_type == "μμμ":
if custom_label:
wandb.log(
{
"train_loss": train_loss,
"train_accuracy": train_acc,
"valid_loss": val_loss,
"valid_accuracy": val_acc,
"best_loss": best_val_loss,
"best_accuracy": best_val_acc,
f"{pill_type[0]}": accuracy_by_label[0],
f"{pill_type[2]}": accuracy_by_label[2],
f"{pill_type[3]}": accuracy_by_label[3],
f"{pill_type[6]}": accuracy_by_label[6],
f"{pill_type[9]}": accuracy_by_label[9],
f"{pill_type[15]}": accuracy_by_label[15],
f"{pill_type[17]}": accuracy_by_label[17],
f"{pill_type[20]}": accuracy_by_label[20],
}
)
else:
wandb.log(
{
"train_loss": train_loss,
"train_accuracy": train_acc,
"valid_loss": val_loss,
"valid_accuracy": val_acc,
"best_loss": best_val_loss,
"best_accuracy": best_val_acc,
f"{pill_type[0]}": accuracy_by_label[0],
f"{pill_type[4]}": accuracy_by_label[4],
f"{pill_type[8]}": accuracy_by_label[8],
f"{pill_type[10]}": accuracy_by_label[10],
f"{pill_type[12]}": accuracy_by_label[12],
f"{pill_type[15]}": accuracy_by_label[15],
f"{pill_type[19]}": accuracy_by_label[19],
f"{pill_type[22]}": accuracy_by_label[22],
f"{pill_type[24]}": accuracy_by_label[24],
f"{pill_type[29]}": accuracy_by_label[29],
}
)
elif project_type == "μμμ_2κ°μ§":
wandb.log(
{
"train_loss": train_loss,
"train_accuracy": train_acc,
"valid_loss": val_loss,
"valid_accuracy": val_acc,
"best_loss": best_val_loss,
"best_accuracy": best_val_acc,
f"{pill_type[0]}": accuracy_by_label[0],
f"{pill_type[1]}": accuracy_by_label[1],
}
)
elif project_type == "μμ½νμ ν":
wandb.log(
{
"train_loss": train_loss,
"train_accuracy": train_acc,
"valid_loss": val_loss,
"valid_accuracy": val_acc,
"best_loss": best_val_loss,
"best_accuracy": best_val_acc,
f"{pill_type[0]}": accuracy_by_label[0],
f"{pill_type[1]}": accuracy_by_label[1],
f"{pill_type[2]}": accuracy_by_label[2],
f"{pill_type[3]}": accuracy_by_label[3],
f"{pill_type[4]}": accuracy_by_label[4],
f"{pill_type[5]}": accuracy_by_label[5],
f"{pill_type[6]}": accuracy_by_label[6],
f"{pill_type[7]}": accuracy_by_label[7],
f"{pill_type[8]}": accuracy_by_label[8],
f"{pill_type[9]}": accuracy_by_label[9],
}
)
elif project_type == "μ±μ":
wandb.log(
{
"train_loss": train_loss,
"train_accuracy": train_acc,
"valid_loss": val_loss,
"valid_accuracy": val_acc,
"best_loss": best_val_loss,
"best_accuracy": best_val_acc,
f"{pill_type[0]}": accuracy_by_label[0],
f"{pill_type[1]}": accuracy_by_label[1],
}
)
elif project_type == "μ±μ_μμ½νμ ν":
wandb.log(
{
"train_loss": train_loss,
"train_accuracy": train_acc,
"valid_loss": val_loss,
"valid_accuracy": val_acc,
"best_loss": best_val_loss,
"best_accuracy": best_val_acc,
f"{pill_type[0]}": accuracy_by_label[0],
f"{pill_type[1]}": accuracy_by_label[1],
f"{pill_type[2]}": accuracy_by_label[2],
f"{pill_type[3]}": accuracy_by_label[3],
f"{pill_type[4]}": accuracy_by_label[4],
f"{pill_type[5]}": accuracy_by_label[5],
f"{pill_type[6]}": accuracy_by_label[6],
f"{pill_type[7]}": accuracy_by_label[7],
f"{pill_type[8]}": accuracy_by_label[8],
f"{pill_type[9]}": accuracy_by_label[9],
f"{pill_type[10]}": accuracy_by_label[10],
}
)