Repository navigation
Expand file tree
/
Copy pathplot_ind.py
More file actions
133 lines (105 loc) · 4.27 KB
/
Copy pathplot_ind.py
File metadata and controls
133 lines (105 loc) · 4.27 KB
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
#!/usr/bin/python
import os
import torch
from tqdm import tqdm
import pdb
saved_file_pre = 'wei-indicator-acc_dict_ep-'
all_epoch = 359
step = 1
#gather_p_handle = open('gather_p_val.txt', 'a')
#gather_p0_handle = open('gather_p0_val.txt', 'a')
#gather_ind_handle = open('gather_ind_val.txt', 'a')
#s10gather_p_handle = open('s10_gather_p_val.txt', 'a')
#s10gather_p0_handle = open('s10_gather_p0_val.txt', 'a')
#s10gather_ind_handle = open('s10_gather_ind_val.txt', 'a')
#s100gather_p_handle = open('s100_gather_p_val.txt', 'a')
#s100gather_p0_handle = open('s100_gather_p0_val.txt', 'a')
#s100gather_ind_handle = open('s100_gather_ind_val.txt', 'a')
#s1000gather_p_handle = open('s1000_gather_p_val.txt', 'a')
#s1000gather_p0_handle = open('s1000_gather_p0_val.txt', 'a')
#s1000gather_ind_handle = open('s1000_gather_ind_val.txt', 'a')
#acc_ind_handle = open('gather_acc_val.txt', 'a')
#trainacc_ind_handle = open('gather_acc_trainval.txt', 'a')
gather_mp_handle = open('gather_p_val.txt', 'a')
gather_mp0_handle = open('gather_p0_val.txt', 'a')
gather_mp_s1_handle = open('gather_p_s1_val.txt', 'a')
gather_mp0_s1_handle = open('gather_p0_s1_val.txt', 'a')
gather_mp_s2_handle = open('gather_p_s2_val.txt', 'a')
gather_mp0_s2_handle = open('gather_p0_s2_val.txt', 'a')
count_bar = tqdm(total=all_epoch/step)
for num in range(1, all_epoch, step):
count_bar.update(1)
p_val_list = []
p0_val_list = []
acc_list = []
ind_list = []
cnt_list = []
pred_list = []
label_list = []
file_name = saved_file_pre + str(num) + '.pt'
data = torch.load(file_name)
for name, raw_sub_data in data.items():
if name == 'val_acc':
#acc_ind_handle.write(str(raw_sub_data[0])+ '\n')
continue
if name == 'train_acc':
#trainacc_ind_handle.write(str(raw_sub_data[0])+ '\n')
continue
sub_data = raw_sub_data[0]
p_val_list.append(sub_data['p_val'])
p0_val_list.append(sub_data['p0_val'])
ind_list.append(sub_data['ind_val'])
cnt_list.append(sub_data['save_cnt'])
pred_list.append(sub_data['pred_pos'])
label_list.append(sub_data['label'])
all_num = len(cnt_list)
p_mean = sum(p_val_list) / len(p_val_list)
p0_mean = sum(p0_val_list) / len(p_val_list)
gather_mp_handle.write(str(p_mean)+ '\n')
gather_mp0_handle.write(str(p0_mean)+ '\n')
if num % 2 == 0:
gather_mp_s2_handle.write(str(p_mean)+ '\n')
gather_mp0_s2_handle.write(str(p0_mean)+ '\n')
else:
gather_mp_s1_handle.write(str(p_mean)+ '\n')
gather_mp0_s1_handle.write(str(p0_mean)+ '\n')
#if num > 160:
# break
#for cnt in cnt_list:
# cnt_index = cnt_list.index(cnt)
# gather_p_handle.write(str(p_val_list[cnt_index])+ '\n')
# gather_p0_handle.write(str(p0_val_list[cnt_index])+ '\n')
# gather_ind_handle.write(str(ind_list[cnt_index])+ '\n')
#
# if cnt %10 == 0:
# s10gather_p_handle.write(str(p_val_list[cnt_index])+ '\n')
# s10gather_p0_handle.write(str(p0_val_list[cnt_index])+ '\n')
# s10gather_ind_handle.write(str(ind_list[cnt_index])+ '\n')
# if cnt %100 == 0:
# s100gather_p_handle.write(str(p_val_list[cnt_index])+ '\n')
# s100gather_p0_handle.write(str(p0_val_list[cnt_index])+ '\n')
# s100gather_ind_handle.write(str(ind_list[cnt_index])+ '\n')
# if cnt %1000 == 0:
# s1000gather_p_handle.write(str(p_val_list[cnt_index])+ '\n')
# s1000gather_p0_handle.write(str(p0_val_list[cnt_index])+ '\n')
# s1000gather_ind_handle.write(str(ind_list[cnt_index])+ '\n')
count_bar.close()
gather_mp_handle.close()
gather_mp0_handle.close()
gather_mp_s1_handle.close()
gather_mp0_s1_handle.close()
gather_mp_s2_handle.close()
gather_mp0_s2_handle.close()
#gather_p_handle.close()
#gather_p0_handle.close()
#gather_ind_handle.close()
#s10gather_p_handle.close()
#s10gather_p0_handle.close()
#s10gather_ind_handle.close()
#s100gather_p_handle.close()
#s100gather_p0_handle.close()
#s100gather_ind_handle.close()
#s1000gather_p_handle.close()
#s1000gather_p0_handle.close()
#s1000gather_ind_handle.close()
#acc_ind_handle.close()