Skip to content

Commit d30de49

Browse files
committed
make the number of nkern for the layer 0 and 1 parametrable.
1 parent d0c7317 commit d30de49

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

code/convolutional_mlp.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def errors(self, y):
178178
raise NotImplementedError()
179179

180180

181-
def evaluate_lenet5(learning_rate=0.1, n_iter=200, dataset='mnist.pkl.gz'):
181+
def evaluate_lenet5(learning_rate=0.1, n_iter=200, dataset='mnist.pkl.gz', nkerns=[20,50]):
182182
rng = numpy.random.RandomState(23455)
183183

184184
# Load the dataset
@@ -224,18 +224,18 @@ def shared_dataset(data_xy):
224224
# Construct the first convolutional pooling layer:
225225
# filtering reduces the image size to (28-5+1,28-5+1)=(24,24)
226226
# maxpooling reduces this further to (24/2,24/2) = (12,12)
227-
# 4D output tensor is thus of shape (batch_size,20,12,12)
227+
# 4D output tensor is thus of shape (batch_size,nkerns[0],12,12)
228228
layer0 = LeNetConvPoolLayer(rng, input=layer0_input,
229229
image_shape=(batch_size,1,28,28),
230-
filter_shape=(20,1,5,5), poolsize=(2,2))
230+
filter_shape=(nkerns[0],1,5,5), poolsize=(2,2))
231231

232232
# Construct the second convolutional pooling layer
233233
# filtering reduces the image size to (12-5+1,12-5+1)=(8,8)
234234
# maxpooling reduces this further to (8/2,8/2) = (4,4)
235-
# 4D output tensor is thus of shape (20,50,4,4)
235+
# 4D output tensor is thus of shape (nkerns[0],nkerns[1],4,4)
236236
layer1 = LeNetConvPoolLayer(rng, input=layer0.output,
237-
image_shape=(batch_size,20,12,12),
238-
filter_shape=(50,20,5,5), poolsize=(2,2))
237+
image_shape=(batch_size,nkerns[0],12,12),
238+
filter_shape=(nkerns[1],nkerns[0],5,5), poolsize=(2,2))
239239

240240
# the SigmoidalLayer being fully-connected, it operates on 2D matrices of
241241
# shape (batch_size,num_pixels) (i.e matrix of rasterized images).
@@ -244,7 +244,7 @@ def shared_dataset(data_xy):
244244

245245
# construct a fully-connected sigmoidal layer
246246
layer2 = SigmoidalLayer(rng, input=layer2_input,
247-
n_in=50*4*4, n_out=500)
247+
n_in=nkerns[1]*4*4, n_out=500)
248248

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

0 commit comments

Comments
 (0)