2019-11-11 14:36:37 -05:00
from utils import *
if __name__ == " __main__ " :
2020-01-13 18:02:36 -05:00
#'''
2019-11-11 14:36:37 -05:00
files = [
2020-02-03 11:21:54 -05:00
" ../res/log/Aug_mod(Data_augV5(Mix0.8-3TFx2-MagFx)-resnet18)-2 epochs (dataug:0)- 1 in_it.json " ,
2020-01-13 18:02:36 -05:00
#"res/brutus-tests/log/Aug_mod(Data_augV5(Uniform-14TFx3-MagFxSh)-LeNet)-150epochs(dataug:0)-10in_it-0.json",
#"res/brutus-tests/log/Aug_mod(Data_augV5(Uniform-14TFx3-MagFxSh)-LeNet)-150epochs(dataug:0)-10in_it-1.json",
#"res/brutus-tests/log/Aug_mod(Data_augV5(Uniform-14TFx3-MagFxSh)-LeNet)-150epochs(dataug:0)-10in_it-2.json",
2019-12-02 06:37:19 -05:00
#"res/log/Aug_mod(RandAugUDA(18TFx2-Mag1)-LeNet)-100 epochs (dataug:0)- 0 in_it.json",
2019-11-11 14:36:37 -05:00
]
2019-11-18 16:48:51 -05:00
for idx , file in enumerate ( files ) :
#legend+=str(idx)+'-'+file+'\n'
with open ( file ) as json_file :
data = json . load ( json_file )
2020-02-03 11:21:54 -05:00
plot_resV2 ( data [ ' Log ' ] , fig_name = file . replace ( " /log " , " " ) . replace ( " .json " , " " ) , param_names = data [ ' Param_names ' ] )
2019-11-20 16:06:27 -05:00
#plot_TF_influence(data['Log'], param_names=data['Param_names'])
2020-01-13 18:02:36 -05:00
#'''
2019-11-18 16:48:51 -05:00
## Loss , Acc, Proba = f(epoch) ##
2019-11-11 14:36:37 -05:00
#plot_compare(filenames=files, fig_name="res/compare")
2019-11-20 16:06:27 -05:00
'''
2019-11-11 14:36:37 -05:00
## Acc, Time, Epochs = f(n_tf) ##
2019-11-14 13:13:03 -05:00
#fig_name="res/TF_nb_tests_compare"
2019-11-12 18:14:10 -05:00
fig_name = " res/TF_seq_tests_compare "
2019-11-14 13:13:03 -05:00
inner_its = [ 0 , 10 ]
2019-11-12 18:14:10 -05:00
dataug_epoch_starts = [ 0 ]
2019-11-14 13:13:03 -05:00
TF_nb = 14 #[len(TF.TF_dict)] #range(10,len(TF.TF_dict)+1) #[len(TF.TF_dict)]
N_seq_TF = [ 1 , 2 , 3 , 4 , 6 ] #[1]
2019-11-11 14:36:37 -05:00
fig , ax = plt . subplots ( ncols = 3 , figsize = ( 30 , 8 ) )
for in_it in inner_its :
for dataug in dataug_epoch_starts :
2019-11-13 16:18:53 -05:00
2019-11-14 13:13:03 -05:00
#n_tf = TF_nb
2019-11-12 18:14:10 -05:00
#filenames =["res/TF_nb_tests/log/Aug_mod(Data_augV4(Uniform-{} TF)-LeNet)-200 epochs (dataug:{})- {} in_it.json".format(n_tf, dataug, in_it) for n_tf in TF_nb]
2019-11-14 13:13:03 -05:00
#filenames =["res/TF_nb_tests/log/Aug_mod(Data_augV4(Uniform-{} TF x {})-LeNet)-200 epochs (dataug:{})- {} in_it.json".format(n_tf, 1, dataug, in_it) for n_tf in TF_nb]
2019-11-13 16:18:53 -05:00
2019-11-14 13:13:03 -05:00
n_tf = N_seq_TF
2019-11-13 16:18:53 -05:00
#filenames =["res/TF_nb_tests/log/Aug_mod(Data_augV4(Uniform-{} TF x {})-LeNet)-200 epochs (dataug:{})- {} in_it.json".format(TF_nb, n_tf, dataug, in_it) for n_tf in N_seq_TF]
2019-11-14 13:13:03 -05:00
filenames = [ " res/TF_nb_tests/log/Aug_mod(Data_augV4(Uniform- {} TF x {} )-LeNet)-200 epochs (dataug: {} )- {} in_it.json " . format ( TF_nb , n_tf , dataug , in_it ) for n_tf in N_seq_TF ]
2019-11-13 11:44:29 -05:00
2019-11-11 14:36:37 -05:00
all_data = [ ]
#legend=""
for idx , file in enumerate ( filenames ) :
#legend+=str(idx)+'-'+file+'\n'
with open ( file ) as json_file :
data = json . load ( json_file )
all_data . append ( data )
2019-11-13 16:18:53 -05:00
2019-11-11 14:36:37 -05:00
acc = [ x [ " Accuracy " ] for x in all_data ]
epochs = [ len ( x [ " Log " ] ) for x in all_data ]
time = [ x [ " Time " ] [ 0 ] for x in all_data ]
#for i in range(len(time)): time[i] *= epochs[i] #Estimation temps total
ax [ 0 ] . plot ( n_tf , acc , label = " {} in_it/ {} dataug " . format ( in_it , dataug ) )
ax [ 1 ] . plot ( n_tf , time , label = " {} in_it/ {} dataug " . format ( in_it , dataug ) )
ax [ 2 ] . plot ( n_tf , epochs , label = " {} in_it/ {} dataug " . format ( in_it , dataug ) )
2019-11-12 11:43:53 -05:00
2019-11-11 14:36:37 -05:00
#for data in all_data:
#print(np.mean([x["param"] for x in data["Log"]], axis=0))
2019-11-12 11:43:53 -05:00
#print(len(data["Param_names"]), np.argsort(np.argsort(np.mean([x["param"] for x in data["Log"]], axis=0))))
2019-11-11 14:36:37 -05:00
ax [ 0 ] . set_title ( ' Acc ' )
ax [ 1 ] . set_title ( ' Time ' )
ax [ 2 ] . set_title ( ' Epochs ' )
for a in ax : a . legend ( )
fig_name = fig_name . replace ( ' . ' , ' , ' )
plt . savefig ( fig_name , bbox_inches = ' tight ' )
2019-11-20 16:06:27 -05:00
plt . close ( )
2019-11-25 16:36:35 +00:00
'''
#Res print
2020-01-13 18:02:36 -05:00
'''
2019-11-25 16:36:35 +00:00
nb_run = 3
accs = [ ]
times = [ ]
2019-12-09 10:46:53 -05:00
files = [ " res/brutus-tests/log/Aug_mod(Data_augV5(Uniform-14TFx3-Mag)-LeNet)-150epochs(dataug:0)-1in_it- %s .json " % str ( run ) for run in range ( nb_run ) ]
2019-11-25 16:36:35 +00:00
for idx , file in enumerate ( files ) :
#legend+=str(idx)+'-'+file+'\n'
with open ( file ) as json_file :
data = json . load ( json_file )
accs . append ( data [ ' Accuracy ' ] )
times . append ( data [ ' Time ' ] [ 0 ] )
2019-12-06 14:13:28 -05:00
print ( idx , data [ ' Accuracy ' ] )
2019-11-25 16:36:35 +00:00
print ( files [ 0 ] , np . mean ( accs ) , np . std ( accs ) , np . mean ( times ) )
2020-02-03 11:21:54 -05:00
'''
'''
inner_its = [ 1 ]
dist_mix = [ 0 ] #[0.5, 0.8, 1.0] #Uniform
N_seq_TF = [ 4 , 3 , 2 ]
nb_run = 3
for n_inner_iter in inner_its :
for n_tf in N_seq_TF :
for dist in dist_mix :
#files = ["../res/brutus-tests2/log/Aug_mod(Data_augV5(Mix%.1f-14TFx%d-MagFxSh)-ResNet18)-150 epochs (dataug:0)- 1 in_it-%s.json"%(dist, n_tf, str(run)) for run in range(nb_run)]
files = [ " ../res/brutus-tests2/log/Aug_mod(Data_augV5(Uniform-14TFx %d -MagFxSh)-ResNet18)-150 epochs (dataug:0)- 1 in_it- %s .json " % ( n_tf , str ( run ) ) for run in range ( nb_run ) ]
accs = [ ]
times = [ ]
for idx , file in enumerate ( files ) :
#legend+=str(idx)+'-'+file+'\n'
with open ( file ) as json_file :
data = json . load ( json_file )
accs . append ( data [ ' Accuracy ' ] )
times . append ( data [ ' Time ' ] [ 0 ] )
print ( idx , data [ ' Accuracy ' ] )
print ( files [ 0 ] , ' acc ' , np . mean ( accs ) , ' +- ' , np . std ( accs ) , ' ,t ' , np . mean ( times ) )
2020-01-13 18:02:36 -05:00
'''