def plot_cost(self):
		if self.show_cost not in self.train_outputs[0][0]:
			raise ShowNetError("Cost function with name '%s' not defined by given convnet." % self.show_cost)
		train_errors = [o[0][self.show_cost][self.cost_idx] for o in self.train_outputs]
		test_errors = [o[0][self.show_cost][self.cost_idx] for o in self.test_outputs]

		numbatches = len(self.train_batch_range)
		test_errors = numpy.row_stack(test_errors)
		test_errors = numpy.tile(test_errors, (1, self.testing_freq))
		test_errors = list(test_errors.flatten())
		test_errors += [test_errors[-1]] * max(0,len(train_errors) - len(test_errors))
		test_errors = test_errors[:len(train_errors)]

		numepochs = len(train_errors) / float(numbatches)
		pl.figure(1)
		x = range(0, len(train_errors))
		pl.plot(x, train_errors, 'k-', label='Training set')
		pl.plot(x, test_errors, 'r-', label='Test set')
		pl.legend()
		ticklocs = range(numbatches, len(train_errors) - len(train_errors) % numbatches + 1, numbatches)
		epoch_label_gran = int(ceil(numepochs / 20.)) # aim for about 20 labels
		epoch_label_gran = int(ceil(float(epoch_label_gran) / 10) * 10) # but round to nearest 10
		ticklabels = map(lambda x: str((x[1] / numbatches)) if x[0] % epoch_label_gran == epoch_label_gran-1 else '', enumerate(ticklocs))

		pl.xticks(ticklocs, ticklabels)
		pl.xlabel('Epoch')
#		pl.ylabel(self.show_cost)
		pl.title(self.show_cost)
dataset/ETHPy150Open zygmuntz/kaggle-cifar/shownet.py/ShowConvNet.plot_cost/original