Skip to content

Commit

Permalink
Merge branch 'dev' of http://github.com/ragavvenkatesan/yann into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragav Venkatesan (Student) authored and Ragav Venkatesan (Student) committed Mar 11, 2017
2 parents 96aa3f5 + 151fa79 commit 82abc8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
6 changes: 3 additions & 3 deletions yann/modules/resultor.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ def _store_confusion_img (self, confusion, filename, verbose = 2):
"""
if verbose >= 3:
print ("... Saving the file down")
confusion = confusion / confusion.max()
confusion = confusion / confusion.sum(axis = 0)
fig = plt.figure()
plt.matshow(confusion)
plt.title('Confusion matrix')
plt.set_cmap('Greens')
plt.set_cmap('GnBu')
plt.colorbar()
plt.ylabel('True labels')
plt.xlabel('Predicated labels')
plt.xlabel('Predicted labels')
plt.savefig(filename)
plt.close('all')
14 changes: 8 additions & 6 deletions yann/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -1935,13 +1935,15 @@ def _initialize_confusion (self, classifier = None, verbose = 2):
print("... initializing confusion matrix function")

_classes = T.scalar('num_classes')
_predictions = self.inference_layers[classifier].predictions
_labels = self.y
_predictions = self.inference_layers[classifier].predictions.dimshuffle(0, 'x')
_labels = self.y.dimshuffle(0, 'x')
_order = T.arange(self.num_classes_to_classify)

oneHot_labels = T.eq(_labels, _order).astype('int32')
oneHot_predictions = T.eq(_predictions, _order).astype('int32')

confusion = T.dot( T.eq( _predictions.dimshuffle(0, 'x'), \
T.arange(self.num_classes_to_classify).astype('int32')).T, \
T.eq( _labels.dimshuffle(0,'x'), \
T.arange(self.num_classes_to_classify).astype('int32')))
confusion = T.dot(oneHot_labels.T, oneHot_predictions)
# confusion_normalized = confusion / confusion.sum(axis = 0)

index = T.lscalar('index')
self.mini_batch_confusion = theano.function(
Expand Down
2 changes: 1 addition & 1 deletion yann/special/gan.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ def train ( self, verbose, **kwargs):
if self.softmax_head is True:
softmax_cost = self.mini_batch_train_softmax (minibatch, epoch_counter)
disc_cost = self.mini_batch_train_discriminator (minibatch, epoch_counter)
if minibatch % k == 0:
if (minibatch + 1) * (batch + 1 ) * (epoch_counter + 1) % k == 0:
gen_cost = self.mini_batch_train_generator (minibatch, epoch_counter)

if numpy.isnan(gen_cost) or \
Expand Down

0 comments on commit 82abc8e

Please sign in to comment.