subpath = os.path.join(args_opt.rootDir,'output',re.sub(r'_epoch_size_[0-9.]*','',key)) if os.path.exists(subpath): import shutil # if exited, remove it! shutil.rmtree(subpath) os.makedirs(subpath,exist_ok=True) strategy_path = os.path.join(subpath,'strategy') csv_abspath = re.sub(r'_epoch_size_[0-9.]*_device_num_\d', '-log.csv', key) csv_path = os.path.join(subpath,csv_abspath) with open(strategy_path,'w') as fp: for item in value['strategy']: fp.write(item+'\n') if 'step' in value['performance'].keys() and\ 'speed' in value['performance'].keys() and\ 'throughput' in value['performance'].keys() and\ 'loss' in value['performance'].keys(): csvfile = CSV( path=csv_path, columns=['step','step_cost_time(ms)','samples/second','loss'], values=[ value['performance']['step'], value['performance']['speed'], value['performance']['throughput'], value['performance']['loss'], ]) csvfile.dump() # print(blocks[1])