-
Notifications
You must be signed in to change notification settings - Fork 3
/
plots.py
82 lines (58 loc) · 2.02 KB
/
plots.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
'''
Created on 19 Oct 2017
@author: vermav1
'''
import argparse
import sys
if sys.version_info[0] < 3:
import cPickle as pickle
else:
import _pickle as pickle
import os
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
import seaborn as sns
sns.set(color_codes=True)
plot_from_index=-10000
def plotting(exp_dir):
# Load the training log dictionary:
train_dict = pickle.load(open(os.path.join(exp_dir, 'log.pkl'), 'rb'))
###########################################################
### Make the vanilla train and test loss per epoch plot ###
###########################################################
plt.plot(np.asarray(train_dict['train_loss']), label='train_loss')
#plt.ylim(0,2000)
plt.xlabel('evaluation step')
plt.ylabel('metrics')
plt.tight_layout()
plt.legend(loc='upper right')
plt.savefig(os.path.join(exp_dir, 'train_loss.png' ))
plt.clf()
plt.plot(np.asarray(train_dict['test_loss']), label='test_loss')
#plt.ylim(0,100)
plt.xlabel('evaluation step')
plt.ylabel('metrics')
plt.tight_layout()
plt.legend(loc='upper right')
plt.savefig(os.path.join(exp_dir, 'test_loss.png' ))
plt.clf()
plt.plot(np.asarray(train_dict['train_acc']), label='train_acc')
#plt.ylim(0,100)
plt.xlabel('evaluation step')
plt.ylabel('metrics')
plt.tight_layout()
plt.legend(loc='upper right')
plt.savefig(os.path.join(exp_dir, 'train_acc.png' ))
plt.clf()
plt.plot(np.asarray(train_dict['test_acc']), label='test_acc')
#plt.ylim(0,100)
plt.xlabel('evaluation step')
plt.ylabel('metrics')
plt.tight_layout()
plt.legend(loc='upper right')
plt.savefig(os.path.join(exp_dir, 'test_acc.png' ))
plt.clf()
if __name__ == '__main__':
plotting('experiments/PB_cnn_mse_pretrained_ne_pretrain100000_ne_posttrain100000_real_data_size1_N10_P2000_')
#plotting_separate_theta('model', 'temp.pkl',3)