File tree 1 file changed +15
-6
lines changed 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -930,20 +930,29 @@ def main():
930
930
# step LR for next epoch
931
931
lr_scheduler .step (epoch + 1 , latest_metric )
932
932
933
- results . append ( {
933
+ latest_results = {
934
934
'epoch' : epoch ,
935
935
'train' : train_metrics ,
936
- 'validation' : eval_metrics ,
937
- })
936
+ }
937
+ if eval_metrics is not None :
938
+ latest_results ['validation' ] = eval_metrics
939
+ results .append (latest_results )
938
940
939
941
except KeyboardInterrupt :
940
942
pass
941
943
942
- results = {'all' : results }
943
944
if best_metric is not None :
944
- results [ ' best' ] = results [ 'all' ][ best_epoch - start_epoch ]
945
+ # log best metric as tracked by checkpoint saver
945
946
_logger .info ('*** Best metric: {0} (epoch {1})' .format (best_metric , best_epoch ))
946
- print (f'--result\n { json .dumps (results , indent = 4 )} ' )
947
+
948
+ if utils .is_primary (args ):
949
+ # for parsable results display, dump top-10 summaries to avoid excess console spam
950
+ display_results = sorted (
951
+ results ,
952
+ key = lambda x : x .get ('validation' , x .get ('train' )).get (eval_metric , 0 ),
953
+ reverse = decreasing_metric ,
954
+ )
955
+ print (f'--result\n { json .dumps (display_results [- 10 :], indent = 4 )} ' )
947
956
948
957
949
958
def train_one_epoch (
You can’t perform that action at this time.
0 commit comments