comparison deep/convolutional_dae/stacked_convolutional_dae.py @ 215:334d2444000d

Changes that enable using this code when floatX=float32
author Dumitru Erhan <dumitru.erhan@gmail.com>
date Wed, 10 Mar 2010 13:48:16 -0500
parents 3f2cc90ad51c
children 4d109b648c31
comparison
equal deleted inserted replaced
210:dc0d77c8a878 215:334d2444000d
54 initial_b = numpy.zeros((filter_shape[0],), dtype=theano.config.floatX) 54 initial_b = numpy.zeros((filter_shape[0],), dtype=theano.config.floatX)
55 self.W = theano.shared(value = initial_W, name = "W") 55 self.W = theano.shared(value = initial_W, name = "W")
56 self.b = theano.shared(value = initial_b, name = "b") 56 self.b = theano.shared(value = initial_b, name = "b")
57 57
58 58
59 initial_b_prime= numpy.zeros((filter_shape[1],)) 59 initial_b_prime= numpy.zeros((filter_shape[1],),dtype=theano.config.floatX)
60 60
61 self.W_prime=T.dtensor4('W_prime') 61 self.W_prime=T.dtensor4('W_prime')
62 62
63 self.b_prime = theano.shared(value = initial_b_prime, name = "b_prime") 63 self.b_prime = theano.shared(value = initial_b_prime, name = "b_prime")
64 64
65 self.x = input 65 self.x = input
66 66
67 self.tilde_x = theano_rng.binomial( self.x.shape, 1, 1 - corruption_level) * self.x 67 self.tilde_x = theano_rng.binomial( self.x.shape, 1, 1 - corruption_level,dtype=theano.config.floatX) * self.x
68 68
69 conv1_out = conv.conv2d(self.tilde_x, self.W, filter_shape=filter_shape, 69 conv1_out = conv.conv2d(self.tilde_x, self.W, filter_shape=filter_shape,
70 image_shape=image_shape, border_mode='valid') 70 image_shape=image_shape, border_mode='valid')
71 71
72 72
133 self.pretrain_functions = [] 133 self.pretrain_functions = []
134 self.params = [] 134 self.params = []
135 self.conv_n_layers = len(conv_hidden_layers_sizes) 135 self.conv_n_layers = len(conv_hidden_layers_sizes)
136 self.mlp_n_layers = len(mlp_hidden_layers_sizes) 136 self.mlp_n_layers = len(mlp_hidden_layers_sizes)
137 137
138 self.x = T.dmatrix('x') # the data is presented as rasterized images 138 self.x = T.matrix('x') # the data is presented as rasterized images
139 self.y = T.ivector('y') # the labels are presented as 1D vector of 139 self.y = T.ivector('y') # the labels are presented as 1D vector of
140 140
141 for i in xrange( self.conv_n_layers ): 141 for i in xrange( self.conv_n_layers ):
142 filter_shape=conv_hidden_layers_sizes[i][0] 142 filter_shape=conv_hidden_layers_sizes[i][0]
143 image_shape=conv_hidden_layers_sizes[i][1] 143 image_shape=conv_hidden_layers_sizes[i][1]
154 poolsize=max_poolsize) 154 poolsize=max_poolsize)
155 print 'Convolutional layer', str(i+1), 'created' 155 print 'Convolutional layer', str(i+1), 'created'
156 156
157 self.layers += [layer] 157 self.layers += [layer]
158 self.params += layer.params 158 self.params += layer.params
159 159
160 da_layer = dA_conv(corruption_level = corruption_levels[0], 160 da_layer = dA_conv(corruption_level = corruption_levels[0],
161 input = layer_input, 161 input = layer_input,
162 shared_W = layer.W, shared_b = layer.b, 162 shared_W = layer.W, shared_b = layer.b,
163 filter_shape = filter_shape, 163 filter_shape = filter_shape,
164 image_shape = image_shape ) 164 image_shape = image_shape )