@@ -8,6 +8,11 @@ Stacked Denoising Autoencoders (SdA)
88 and :doc:`mlp`. Additionally it uses the following Theano functions
99 and concepts : TODO
1010
11+ .. note::
12+ The code for this section is available for download `here`_.
13+
14+ .. _here: http://deeplearning.net/tutorial/code/SdA.py
15+
1116
1217The Stacked Denoising Autoencoder (SdA) is an extension of the stacked
1318autoencoder [Bengio07]_ and it was introduced in [Vincent08]_. We will start the
@@ -102,11 +107,11 @@ autoencoder ( :math:`\mathbf{W}`, :math:`\mathbf{b}` and
102107 # the output of uniform if converted using asarray to dtype
103108 # theano.config.floatX so that the code is runable on GPU
104109 initial_W = numpy.asarray( numpy.random.uniform( \
105- low = -numpy.sqrt(6./(n_visible+n_hidden)), \
106- high = numpy.sqrt(6./(n_visible+n_hidden)), \
107- size = (n_visible, n_hidden)), dtype = theano.config.floatX)
110+ low = -numpy.sqrt(6./(n_visible+n_hidden)), \
111+ high = numpy.sqrt(6./(n_visible+n_hidden)), \
112+ size = (n_visible, n_hidden)), dtype = theano.config.floatX)
108113 initial_b = numpy.zeros(n_hidden)
109- initial_b_prime= numpy.zeros(n_visible)
114+ initial_b_prime = numpy.zeros(n_visible)
110115
111116
112117 # theano shared variables for weights and biases
@@ -127,11 +132,11 @@ signal:
127132
128133.. code-block:: python
129134
130- self.y = T.nnet.sigmoid(T.dot(self.x, self.W ) + self.b)
131- self.z = T.nnet.sigmoid(T.dot(self.y, self.W_prime) + self.b_prime)
135+ self.y = T.nnet.sigmoid(T.dot(self.x, self.W ) + self.b)
136+ self.z = T.nnet.sigmoid(T.dot(self.y, self.W_prime) + self.b_prime)
132137 # note : we sum over the size of a data point; if we are using minibatches,
133138 # L will be a vector, with one entry per example in minibatch
134- self.L = - T.sum( self.x*T.log(self.z) + (1-self.x)*T.log(1-self.z), axis=1 )
139+ self.L = - T.sum( self.x*T.log(self.z) + (1-self.x)*T.log(1-self.z), axis=1 )
135140 # note : L is now a vector, where each element is the cross-entropy cost
136141 # of the reconstruction of the corresponding example of the
137142 # minibatch. We need to compute the average of all these to get
@@ -283,15 +288,15 @@ The final denoising autoencoder class becomes :
283288 # the output of uniform if converted using asarray to dtype
284289 # theano.config.floatX so that the code is runable on GPU
285290 initial_W = numpy.asarray( numpy.random.uniform( \
286- low = -numpy.sqrt(6./(n_hidden+n_visible)), \
287- high = numpy.sqrt(6./(n_hidden+n_visible)), \
288- size = (n_visible, n_hidden)), dtype = theano.config.floatX)
289- initial_b = numpy.zeros(n_hidden)
291+ low = -numpy.sqrt(6./(n_hidden+n_visible)), \
292+ high = numpy.sqrt(6./(n_hidden+n_visible)), \
293+ size = (n_visible, n_hidden)), dtype = theano.config.floatX)
294+ initial_b = numpy.zeros(n_hidden)
290295
291296
292297 # theano shared variables for weights and biases
293- self.W = theano.shared(value = initial_W, name = "W")
294- self.b = theano.shared(value = initial_b, name = "b")
298+ self.W = theano.shared(value = initial_W, name = "W")
299+ self.b = theano.shared(value = initial_b, name = "b")
295300
296301
297302 initial_b_prime= numpy.zeros(n_visible)
@@ -399,7 +404,7 @@ representations of intermediate layers of the MLP.
399404 :param pretrain_lr: learning rate used during pre-trainnig stage
400405
401406 :param finetune_lr: learning rate used during finetune stage
402-
407+ """
403408 self.layers = []
404409 self.pretrain_functions = []
405410 self.params = []
@@ -410,12 +415,12 @@ representations of intermediate layers of the MLP.
410415
411416
412417 # allocate symbolic variables for the data
413- index = T.lscalar() # index to a [mini]batch
414- self.x = T.matrix('x') # the data is presented as rasterized images
415- self.y = T.ivector('y') # the labels are presented as 1D vector of
418+ index = T.lscalar() # index to a [mini]batch
419+ self.x = T.matrix('x') # the data is presented as rasterized images
420+ self.y = T.ivector('y') # the labels are presented as 1D vector of
416421 # [int] labels
417422
418- """
423+
419424
420425``self.layers`` will store the sigmoid layers of the MLP facade, while
421426``self.pretrain_function`` will store compiled Theano function to train
0 commit comments