# HG changeset patch # User SylvainPL # Date 1270842582 14400 # Node ID 048898c1ee551755893341b64e9a194f8403f633 # Parent 1763c64030d16a2536e8500912ff5ebf4e8316c4 Ajout d'une fonction pour calculer l'erreur effectuee par le modele sur un ensemble pre-determine diff -r 1763c64030d1 -r 048898c1ee55 deep/stacked_dae/v_sylvain/sgd_optimization.py --- a/deep/stacked_dae/v_sylvain/sgd_optimization.py Thu Apr 08 11:22:11 2010 -0400 +++ b/deep/stacked_dae/v_sylvain/sgd_optimization.py Fri Apr 09 15:49:42 2010 -0400 @@ -341,6 +341,19 @@ self.classifier.params[idx].value=theano._asarray(copy(x),dtype=theano.config.floatX) else: self.classifier.params[idx].value=copy(x) + + #Calculate error over the training set (or a part of) + def training_error(self,data): + # create a function to compute the mistakes that are made by the model + # on the validation set, or testing set + test_model = \ + theano.function( + [self.classifier.x,self.classifier.y], self.classifier.errors) + + iter2 = data.train(self.hp.minibatch_size,bufsize=buffersize) + train_losses2 = [test_model(x,y) for x,y in iter2] + train_score2 = numpy.mean(train_losses2) + print "Training error is: " + str(train_score2)