Mercurial > ift6266
comparison deep/stacked_dae/v_sylvain/sgd_optimization.py @ 235:ecb69e17950b
correction de bugs
author | SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca> |
---|---|
date | Sun, 14 Mar 2010 20:25:12 -0400 |
parents | 02ed13244133 |
children | 9fc641d7adda |
comparison
equal
deleted
inserted
replaced
234:c452e3a0a3b1 | 235:ecb69e17950b |
---|---|
116 ## Pre-train layer-wise | 116 ## Pre-train layer-wise |
117 for i in xrange(self.classifier.n_layers): | 117 for i in xrange(self.classifier.n_layers): |
118 # go through pretraining epochs | 118 # go through pretraining epochs |
119 for epoch in xrange(self.hp.pretraining_epochs_per_layer): | 119 for epoch in xrange(self.hp.pretraining_epochs_per_layer): |
120 # go through the training set | 120 # go through the training set |
121 batch_index=int(0) | |
121 for x,y in dataset.train(self.hp.minibatch_size): | 122 for x,y in dataset.train(self.hp.minibatch_size): |
122 c = self.classifier.pretrain_functions[i](x) | 123 c = self.classifier.pretrain_functions[i](x) |
123 | 124 batch_index+=1 |
125 | |
124 self.series["reconstruction_error"].append((epoch, batch_index), c) | 126 self.series["reconstruction_error"].append((epoch, batch_index), c) |
125 | 127 |
126 print 'Pre-training layer %i, epoch %d, cost '%(i,epoch),c | 128 print 'Pre-training layer %i, epoch %d, cost '%(i,epoch),c |
127 sys.stdout.flush() | 129 sys.stdout.flush() |
128 | 130 |
138 def finetune(self,dataset): | 140 def finetune(self,dataset): |
139 print "STARTING FINETUNING, time = ", datetime.datetime.now() | 141 print "STARTING FINETUNING, time = ", datetime.datetime.now() |
140 | 142 |
141 #index = T.lscalar() # index to a [mini]batch | 143 #index = T.lscalar() # index to a [mini]batch |
142 minibatch_size = self.hp.minibatch_size | 144 minibatch_size = self.hp.minibatch_size |
145 ensemble_x = T.matrix('ensemble_x') | |
146 ensemble_y = T.ivector('ensemble_y') | |
143 | 147 |
144 # create a function to compute the mistakes that are made by the model | 148 # create a function to compute the mistakes that are made by the model |
145 # on the validation set, or testing set | 149 # on the validation set, or testing set |
146 shared_divider = theano.shared(numpy.asarray(self.input_divider, dtype=theano.config.floatX)) | 150 shared_divider = theano.shared(numpy.asarray(self.input_divider, dtype=theano.config.floatX)) |
147 test_model = theano.function([ensemble_x,ensemble_y], self.classifier.errors, | 151 test_model = theano.function([ensemble_x,ensemble_y], self.classifier.errors, |