@@ -23,7 +23,7 @@ def __init__(self, path_to_log, path_to_save, experiment_list, metric_list, comb
23
23
:param title: <str> Title of the plot
24
24
"""
25
25
self .path_to_log = path_to_log
26
- self .val_only = val_only
26
+ self .test_only = val_only
27
27
self .metric_list = metric_list
28
28
self .combine = combine
29
29
self .title = title
@@ -80,25 +80,28 @@ def create_train_val_plot(self, field, tf_log, exp, title=None, legend_label=Non
80
80
:param legend_label: <str> specify legend name
81
81
:return:
82
82
"""
83
- train , val , epoch = [], [], []
83
+ train , val , test , epoch = [], [], [], []
84
84
for e in tf .train .summary_iterator (tf_log ):
85
85
for v in e .summary .value :
86
86
if v .tag == 'train_{}' .format (field ):
87
87
train .append (v .simple_value )
88
88
epoch .append (e .step )
89
89
if v .tag == 'val_{}' .format (field ):
90
90
val .append (v .simple_value )
91
+ if v .tag == 'test_{}' .format (field ):
92
+ test .append (v .simple_value )
91
93
92
94
# save as plot
93
- if not self .val_only :
94
- plt .plot (epoch , train , '--' , label = 'train {} {}' .format (field , legend_label if legend_label else '' ))
95
- plt .plot (epoch , val , '--' , label = 'val {} {}' .format (field , legend_label if legend_label else '' ))
95
+ if not self .test_only :
96
+ plt .plot (epoch , train , '-' , label = 'train {} {}' .format (field , legend_label if legend_label else '' ))
97
+ plt .plot (epoch , val , '-' , label = 'val {} {}' .format (field , legend_label if legend_label else '' ))
98
+ plt .plot (epoch , test , '-' , label = 'test {} {}' .format (field , legend_label if legend_label else '' ))
96
99
plt .xlabel ('Epoch' )
97
100
plt .legend (loc = 'best' )
98
101
if title :
99
102
plt .title (title )
100
103
else :
101
- plt .title ('train {0} vs. val {0}' .format (field ))
104
+ plt .title ('train {0}, val {0} and test {0}' .format (field ))
102
105
103
106
if not self .combine :
104
107
save_fig_to = os .path .join (self .path_to_save , exp , '{}_train_val_{}.pdf' .format (exp , field ))
@@ -115,7 +118,7 @@ def create_train_val_plot(self, field, tf_log, exp, title=None, legend_label=Non
115
118
default = '../' )
116
119
parser .add_argument ("--experiment_list" , help = 'Experiments to parse logs for.' , nargs = '*' , default = None )
117
120
parser .add_argument ("--combine" , help = 'If used, combines plots across experiments' , action = 'store_true' )
118
- parser .add_argument ("--val_only " , help = 'If used, combines plots across experiments for val metrics only' , action = 'store_true' )
121
+ parser .add_argument ("--test_only " , help = 'If used, combines plots across experiments for test metrics only' , action = 'store_true' )
119
122
parser .add_argument ("--legend_labels" , help = 'List of labels for the legend' , nargs = '*' , default = None )
120
123
parser .add_argument ("--title" , help = 'List of labels for the legend' , type = str , default = None )
121
124
parser .add_argument ("--metric_list" , help = 'Metrics to plot.' , nargs = '*' , default = ['macro_f1' , 'micro_f1' , 'loss' ,
@@ -129,7 +132,7 @@ def create_train_val_plot(self, field, tf_log, exp, title=None, legend_label=Non
129
132
experiment_list = args .experiment_list ,
130
133
metric_list = args .metric_list ,
131
134
combine = args .combine ,
132
- val_only = args .val_only ,
135
+ val_only = args .test_only ,
133
136
legend_labels = args .legend_labels ,
134
137
title = args .title )
135
138
clog .convert_exp ()
0 commit comments