MCPcopy Create free account
hub / github.com/cure-lab/deep-active-learning / plot_curve

Method plot_curve

utils.py:76–139  ·  view source on GitHub ↗
(self, save_path)

Source from the content-addressed store, hash-verified

74 else: return self.epoch_accuracy[:self.current_epoch, 1].max()
75
76 def plot_curve(self, save_path):
77 title = 'the accuracy/loss curve of train/val'
78 dpi = 80
79 width, height = 1200, 800
80 legend_fontsize = 10
81 scale_distance = 48.8
82 figsize = width / float(dpi), height / float(dpi)
83
84 fig = plt.figure(figsize=figsize)
85 x_axis = np.array([i for i in range(self.total_epoch)]) # epochs
86 y_axis = np.zeros(self.total_epoch)
87
88 plt.xlim(0, self.total_epoch)
89 plt.ylim(0, 1)
90 interval_y = 0.05
91 interval_x = 5
92 plt.xticks(np.arange(0, self.total_epoch + interval_x, interval_x))
93 plt.yticks(np.arange(0, 1 + interval_y, interval_y))
94 plt.grid()
95 plt.title(title, fontsize=20)
96 plt.xlabel('the training epoch', fontsize=16)
97 plt.ylabel('accuracy', fontsize=16)
98
99 y_axis[:] = self.epoch_accuracy[:, 0]
100 plt.plot(x_axis,
101 y_axis,
102 color='g',
103 linestyle='-',
104 label='train-accuracy',
105 lw=2)
106 plt.legend(loc=4, fontsize=legend_fontsize)
107
108 y_axis[:] = self.epoch_accuracy[:, 1]
109 plt.plot(x_axis,
110 y_axis,
111 color='y',
112 linestyle='-',
113 label='valid-accuracy',
114 lw=2)
115 plt.legend(loc=4, fontsize=legend_fontsize)
116
117 y_axis[:] = self.epoch_losses[:, 0]
118 plt.plot(x_axis,
119 y_axis * 50,
120 color='g',
121 linestyle=':',
122 label='train-loss-x50',
123 lw=2)
124 plt.legend(loc=4, fontsize=legend_fontsize)
125
126 y_axis[:] = self.epoch_losses[:, 1]
127 plt.plot(x_axis,
128 y_axis * 50,
129 color='y',
130 linestyle=':',
131 label='valid-loss-x50',
132 lw=2)
133 plt.legend(loc=4, fontsize=legend_fontsize)

Callers 6

trainMethod · 0.95
trainMethod · 0.95
trainMethod · 0.95
trainMethod · 0.95
trainMethod · 0.95
trainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected