-
Notifications
You must be signed in to change notification settings - Fork 1
/
fraction_plot.py
87 lines (72 loc) · 2.34 KB
/
fraction_plot.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
import tensorflow as tf
import numpy as np
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import os
'''
Reading from list of model files of paths and, print the final fraction order of the experiment in a list and plot and save the change of fraction order for each experiment
'''
#fig_dir= directiort to save figures
#source_path = directory that contains many experiment
#file_lst = []
#for root, dirs, files in os.walk(source_path):
# if not root.split('/')[-1] == 'weights':
# #print(dirs)
# #print(files)
# for file in files:
# if file.split('.')[0] == 'events':
# file_lst.append(os.path.join(root, file))
#
#
#counter = 0
#learned_frac_list= []
#total_iter=100
#for event_path in file_lst:
#
# counter=counter+1
# iterit=0
# value_list= []
# for e in tf.compat.v1.train.summary_iterator(event_path):
# for v in e.summary.value:
# if v.tag == 'fraction_order/fraction':
# iterit=iterit+1
# value_list.append(v.simple_value)
# if iterit==total_iter:
# learned_frac_list.append(v.simple_value)
# #print(v.simple_value)
# #print("Iteration", iterit)
# x_ax=np.arange(1,iterit+1)
# plt.title(" Iteration vs Fraction Order (a)" )
# plt.xlabel('Iterations')
# plt.ylabel('a')
# plt.figure()
# plt.plot(x_ax,value_list)
#
# fig_name= #figure names
# plt.savefig(fig_dir+fig_name)
#
#
#
#with open("fraction_list.txt", "w") as output:
# output.write(str(learned_frac_list))
'''
Only one experiment. Print and plot the fraction orders
'''
iterit=0
value_list= []
event_path= # path of the events in a path
for e in tf.compat.v1.train.summary_iterator(event_path):
for v in e.summary.value:
if v.tag == 'fraction_order/fraction':
iterit=iterit+1
value_list.append(v.simple_value)
print(v.simple_value)
print("Iteration", iterit)
x_ax=np.arange(1,iterit+1)
plt.title(" Iteration vs Fraction Order (a)" )
plt.xlabel('Iterations')
plt.ylabel('a')
plt.plot(x_ax,value_list)
fig_name= #figure name
plt.savefig(fig_name)