Skip to content

Commit 9525863

Browse files
committed
updates hyperparameters of lenet network
1 parent 865ed2c commit 9525863

2 files changed

Lines changed: 15 additions & 17 deletions

File tree

code/convolutional_mlp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def load_dataset(fname):
220220
return train_batches, valid_batches, test_batches
221221

222222

223-
def evaluate_lenet5(learning_rate=0.01, n_iter=200, dataset='mnist.pkl.gz'):
223+
def evaluate_lenet5(learning_rate=0.1, n_iter=200, dataset='mnist.pkl.gz'):
224224
rng = numpy.random.RandomState(23455)
225225

226226
train_batches, valid_batches, test_batches = load_dataset(dataset)

doc/lenet.txt

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ instantiate the network as follows.
443443

444444
.. code-block:: python
445445

446-
learning_rate = 0.001
446+
learning_rate = 0.1
447447
rng = numpy.random.RandomState(23455)
448448

449449
train_batches, valid_batches, test_batches = load_dataset(dataset)
@@ -466,31 +466,32 @@ instantiate the network as follows.
466466
# Construct the first convolutional pooling layer:
467467
# filtering reduces the image size to (28-5+1,28-5+1)=(24,24)
468468
# maxpooling reduces this further to (24/2,24/2) = (12,12)
469-
# 4D output tensor is thus of shape (20,6,12,12)
469+
# 4D output tensor is thus of shape (20,20,12,12)
470470
layer0 = LeNetConvPoolLayer(rng, input=layer0_input,
471-
image_shape=(batch_size,1,28,28),
472-
filter_shape=(6,1,5,5), poolsize=(2,2))
471+
image_shape=(batch_size,1,28,28),
472+
filter_shape=(20,1,5,5), poolsize=(2,2))
473473

474474
# Construct the second convolutional pooling layer
475475
# filtering reduces the image size to (12-5+1,12-5+1)=(8,8)
476476
# maxpooling reduces this further to (8/2,8/2) = (4,4)
477-
# 4D output tensor is thus of shape (20,32,4,4)
477+
# 4D output tensor is thus of shape (20,50,4,4)
478478
layer1 = LeNetConvPoolLayer(rng, input=layer0.output,
479-
image_shape=(batch_size,6,12,12),
480-
filter_shape=(32,6,5,5), poolsize=(2,2))
479+
image_shape=(batch_size,20,12,12),
480+
filter_shape=(50,20,5,5), poolsize=(2,2))
481481

482482
# the SigmoidalLayer being fully-connected, it operates on 2D matrices of
483483
# shape (batch_size,num_pixels) (i.e matrix of rasterized images).
484484
# This will generate a matrix of shape (20,32*4*4) = (20,512)
485485
layer2_input = layer1.output.flatten(2)
486486

487487
# construct a fully-connected sigmoidal layer
488-
layer2 = SigmoidalLayer(rng, input=layer2_input,
489-
n_in=32*4*4, n_out=500)
488+
layer2 = SigmoidalLayer(rng, input=layer2_input,
489+
n_in=50*4*4, n_out=500)
490490

491491
# classify the values of the fully-connected sigmoidal layer
492492
layer3 = LogisticRegression(input=layer2.output, n_in=500, n_out=10)
493493

494+
494495
# the cost we minimize during training is the NLL of the model
495496
cost = layer3.negative_log_likelihood(y)
496497

@@ -527,20 +528,17 @@ The following output was obtained with a learning rate of 0.1:
527528

528529
.. code-block:: bash
529530

530-
Best validation score of 1.080000 % obtained at iteration 27499,with test
531-
performance 1.090000 %
532-
The code ran for 62.096667 minutes
533-
531+
Optimization complete.
532+
Best validation score of 0.900000 % obtained at iteration 12499,with test
533+
performance 0.990000 %
534+
The code ran for 85.694333 minutes
534535

535536
Tips and Tricks
536537
+++++++++++++++
537538

538539
Choosing Hyperparameters
539540
------------------------
540541

541-
Running on the GPU
542-
------------------
543-
544542

545543
References
546544
++++++++++

0 commit comments

Comments
 (0)