Imagenette/woof training
This is an example of how to analyze the results logged by a number of runs of fastgpu
on Imagenette.
path = Path('~/git/fastai/nbs/examples/exps').expanduser()
path_out = path/'out'
path_scr = path/'complete'
def fn_name(fn): return fn.name.split('.')[0]
hdrs = 'name epoch trn_loss val_loss top1 top5 time'.split()
def scr_results(fn):
return L([dict(zip(hdrs, [fn_name(fn)] + o.strip().split()))
for o in fn.readlines() if re.match(r'\d+ ', o)])
all_results = L([scr_results(o) for o in path_out.glob('*.stdout')]).concat()
df_results = DataFrame.from_records(all_results).query('time==time').astype(
dict(epoch=int, trn_loss=float, val_loss=float, top5=float, top1=float))
def scr_params(fn):
return merge(dict([o.strip().split() for o in fn.read_text().split('--')[1:]]),
{'name':fn_name(fn)})
df_params = DataFrame([scr_params(o) for o in path_scr.ls()]).astype({'epochs':int})
df_params.head()
df_merge = pd.merge(df_params, df_results, 'left', on='name')
assert df_merge[pd.isna(df_merge.arch)].empty
df_merge.fillna(0.0, inplace=True)
df_merge['repoch'] = df_merge.epochs - df_merge.epoch
df_merge.to_csv('imagenette.csv', index=False)
FileLink('imagenette.csv')