In [66]:
%matplotlib inline
from glob import glob
import pickle, matplotlib.pyplot as plt
import matplotlib.patches as mpatches
In [4]:
def load_lists(test_num, tf_method):
d_path = '/Users/c.albert/Dissertation/lists/test{}/{}'.format(test_num, tf_method)
return (pickle.load( open(d_path+'_avg_loss_list.pkl', 'rb') ),
pickle.load( open(d_path+'_epochs_list.pkl', 'rb')),
pickle.load( open(d_path+'_times_list.pkl', 'rb')))
In [25]:
def create_list_dict(test_num):
dic = {}
for tf_method in ['graduated', 'graduated_reset', 'full', 'none', 'p25', 'p50', 'p75']:
dic[tf_method+'_avg_loss'], dic[tf_method+'_epochs'], dic[tf_method+'_times'] = load_lists(test_num, tf_method)
return dic
In [61]:
t1_dict = create_list_dict(1)
t2_dict = create_list_dict(2)
t3_dict = create_list_dict(3)
In [94]:
def plot_test(t_dict, t_num):
plt.subplot(121)
plt.plot(t_dict['p75_times'], t_dict['p75_avg_loss'], 'r-',
t_dict['p50_times'], t_dict['p50_avg_loss'], 'b-',
t_dict['p25_times'], t_dict['p25_avg_loss'], 'y-',
t_dict['none_times'], t_dict['none_avg_loss'], 'g-',
t_dict['full_times'], t_dict['full_avg_loss'], 'k-',
t_dict['graduated_times'], t_dict['graduated_avg_loss'], 'c-',
t_dict['graduated_reset_times'], t_dict['graduated_reset_avg_loss'], 'm-')
plt.xlabel('Training Time (Minutes)')
plt.ylabel('Average Loss')
plt.tight_layout()
plt.axis([0, 235, 0, 3])
red_patch = mpatches.Patch(color='red', label='75%')
b_patch = mpatches.Patch(color='blue', label='50%')
y_patch = mpatches.Patch(color='yellow', label='25%')
g_patch = mpatches.Patch(color='green', label='0%')
k_patch = mpatches.Patch(color='black', label='100%')
c_patch = mpatches.Patch(color='cyan', label='Graduated')
m_patch = mpatches.Patch(color='magenta', label='Reset-graduated')
plt.legend(handles=[red_patch, b_patch, y_patch, g_patch, k_patch, c_patch, m_patch])
plt.subplot(122)
plt.plot(t_dict['p75_times'], t_dict['p75_avg_loss'], 'r-',
t_dict['p50_times'], t_dict['p50_avg_loss'], 'b-',
t_dict['p25_times'], t_dict['p25_avg_loss'], 'y-',
t_dict['none_times'], t_dict['none_avg_loss'], 'g-',
t_dict['full_times'], t_dict['full_avg_loss'], 'k-',
t_dict['graduated_times'], t_dict['graduated_avg_loss'], 'c-',
t_dict['graduated_reset_times'], t_dict['graduated_reset_avg_loss'], 'm-')
plt.xlabel('Training Time (Minutes)')
plt.ylabel('Average Loss')
plt.axis([200, 235, 0, .5])
plt.legend()
plt.tight_layout()
plt.savefig('./plots/test{}comb.png'.format(t_num))
plt.show()
In [95]:
fig_size = plt.rcParams["figure.figsize"]; fig_size
Out[95]:
In [96]:
fig_size[0], fig_size[1] = (12,4)
In [97]:
plot_test(t2_dict, 2)
In [98]:
plot_test(t1_dict, 1)
In [99]:
plot_test(t3_dict, 3)