@@ -62,7 +62,7 @@ def __init__(self, rng, input, n_in, n_out, W=None, b=None,
6262
6363 :type activation: theano.Op or function
6464 :param activation: Non linearity to be applied in the hidden
65- layer
65+ layer
6666 """
6767 self .input = input
6868
@@ -174,7 +174,7 @@ def __init__(self, rng, input, n_in, n_hidden, n_out):
174174
175175
176176def test_mlp (learning_rate = 0.01 , L1_reg = 0.00 , L2_reg = 0.0001 , n_epochs = 1000 ,
177- dataset = '../data/mnist.pkl.gz' , batch_size = 20 ):
177+ dataset = '../data/mnist.pkl.gz' , batch_size = 20 , n_hidden = 500 ):
178178 """
179179 Demonstrate stochastic gradient descent optimization for a multilayer
180180 perceptron
@@ -219,15 +219,16 @@ def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000,
219219 print '... building the model'
220220
221221 # allocate symbolic variables for the data
222- index = T .lscalar () # index to a [mini]batch
222+ index = T .lscalar () # index to a [mini]batch
223223 x = T .matrix ('x' ) # the data is presented as rasterized images
224224 y = T .ivector ('y' ) # the labels are presented as 1D vector of
225225 # [int] labels
226226
227227 rng = numpy .random .RandomState (1234 )
228228
229229 # construct the MLP class
230- classifier = MLP (rng = rng , input = x , n_in = 28 * 28 , n_hidden = 500 , n_out = 10 )
230+ classifier = MLP (rng = rng , input = x , n_in = 28 * 28 ,
231+ n_hidden = n_hidden , n_out = 10 )
231232
232233 # the cost we minimize during training is the negative log likelihood of
233234 # the model plus the regularization terms (L1 and L2); cost is expressed
@@ -259,10 +260,10 @@ def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000,
259260
260261 # specify how to update the parameters of the model as a dictionary
261262 updates = {}
262- # given two list the zip A = [ a1,a2,a3,a4] and B = [b1,b2,b3,b4] of
263+ # given two list the zip A = [a1, a2, a3, a4] and B = [b1, b2, b3, b4] of
263264 # same length, zip generates a list C of same size, where each element
264265 # is a pair formed from the two lists :
265- # C = [ (a1,b1), (a2,b2), (a3,b3) , (a4,b4) ]
266+ # C = [(a1, b1), (a2, b2), (a3, b3), (a4, b4)]
266267 for param , gparam in zip (classifier .params , gparams ):
267268 updates [param ] = param - learning_rate * gparam
268269
0 commit comments