@@ -90,16 +90,16 @@ def __init__(self, rng, input, filter_shape, image_shape, poolsize=(2, 2)):
9090
9191 # convolve input feature maps with filters
9292 conv_out = conv .conv2d (
93- input = input ,
93+ input = input ,
9494 filters = self .W ,
95- filter_shape = filter_shape ,
95+ filter_shape = filter_shape ,
9696 image_shape = image_shape
9797 )
9898
9999 # downsample each feature map individually, using maxpooling
100100 pooled_out = downsample .max_pool_2d (
101101 input = conv_out ,
102- ds = poolsize ,
102+ ds = poolsize ,
103103 ignore_border = True
104104 )
105105
@@ -170,7 +170,7 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200,
170170 # maxpooling reduces this further to (24/2,24/2) = (12,12)
171171 # 4D output tensor is thus of shape (batch_size,nkerns[0],12,12)
172172 layer0 = LeNetConvPoolLayer (
173- rng ,
173+ rng ,
174174 input = layer0_input ,
175175 image_shape = (batch_size , 1 , 28 , 28 ),
176176 filter_shape = (nkerns [0 ], 1 , 5 , 5 ),
@@ -182,10 +182,10 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200,
182182 # maxpooling reduces this further to (8/2,8/2) = (4,4)
183183 # 4D output tensor is thus of shape (nkerns[0],nkerns[1],4,4)
184184 layer1 = LeNetConvPoolLayer (
185- rng ,
185+ rng ,
186186 input = layer0 .output ,
187187 image_shape = (batch_size , nkerns [0 ], 12 , 12 ),
188- filter_shape = (nkerns [1 ], nkerns [0 ], 5 , 5 ),
188+ filter_shape = (nkerns [1 ], nkerns [0 ], 5 , 5 ),
189189 poolsize = (2 , 2 )
190190 )
191191
@@ -196,10 +196,10 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200,
196196
197197 # construct a fully-connected sigmoidal layer
198198 layer2 = HiddenLayer (
199- rng ,
200- input = layer2_input ,
199+ rng ,
200+ input = layer2_input ,
201201 n_in = nkerns [1 ] * 4 * 4 ,
202- n_out = 500 ,
202+ n_out = 500 ,
203203 activation = T .tanh
204204 )
205205
@@ -211,20 +211,20 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200,
211211
212212 # create a function to compute the mistakes that are made by the model
213213 test_model = theano .function (
214- [index ],
214+ [index ],
215215 layer3 .errors (y ),
216216 givens = {
217- x : test_set_x [index * batch_size : (index + 1 ) * batch_size ],
218- y : test_set_y [index * batch_size : (index + 1 ) * batch_size ]
217+ x : test_set_x [index * batch_size : (index + 1 ) * batch_size ],
218+ y : test_set_y [index * batch_size : (index + 1 ) * batch_size ]
219219 }
220220 )
221221
222222 validate_model = theano .function (
223- [index ],
223+ [index ],
224224 layer3 .errors (y ),
225225 givens = {
226- x : valid_set_x [index * batch_size : (index + 1 ) * batch_size ],
227- y : valid_set_y [index * batch_size : (index + 1 ) * batch_size ]
226+ x : valid_set_x [index * batch_size : (index + 1 ) * batch_size ],
227+ y : valid_set_y [index * batch_size : (index + 1 ) * batch_size ]
228228 }
229229 )
230230
@@ -245,12 +245,12 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200,
245245 ]
246246
247247 train_model = theano .function (
248- [index ],
249- cost ,
248+ [index ],
249+ cost ,
250250 updates = updates ,
251251 givens = {
252- x : train_set_x [index * batch_size : (index + 1 ) * batch_size ],
253- y : train_set_y [index * batch_size : (index + 1 ) * batch_size ]
252+ x : train_set_x [index * batch_size : (index + 1 ) * batch_size ],
253+ y : train_set_y [index * batch_size : (index + 1 ) * batch_size ]
254254 }
255255 )
256256
@@ -312,10 +312,13 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200,
312312 best_iter = iter
313313
314314 # test it on the test set
315- test_losses = [test_model (i ) for i in xrange (n_test_batches )]
315+ test_losses = [
316+ test_model (i )
317+ for i in xrange (n_test_batches )
318+ ]
316319 test_score = numpy .mean (test_losses )
317- print ((' epoch %i, minibatch %i/%i, test error of best '
318- 'model %f %%' ) %
320+ print ((' epoch %i, minibatch %i/%i, test error of '
321+ 'best model %f %%' ) %
319322 (epoch , minibatch_index + 1 , n_train_batches ,
320323 test_score * 100. ))
321324
0 commit comments