MCPcopy Index your code
hub / github.com/lisa-lab/DeepLearningTutorials / test_cA

Function test_cA

code/cA.py:231–312  ·  view source on GitHub ↗

This demo is tested on MNIST :type learning_rate: float :param learning_rate: learning rate used for training the contracting AutoEncoder :type training_epochs: int :param training_epochs: number of epochs used for training :type dataset: string

(learning_rate=0.01, training_epochs=20,
            dataset='mnist.pkl.gz',
            batch_size=10, output_folder='cA_plots', contraction_level=.1)

Source from the content-addressed store, hash-verified

229
230
231def test_cA(learning_rate=0.01, training_epochs=20,
232 dataset='mnist.pkl.gz',
233 batch_size=10, output_folder='cA_plots', contraction_level=.1):
234 """
235 This demo is tested on MNIST
236
237 :type learning_rate: float
238 :param learning_rate: learning rate used for training the contracting
239 AutoEncoder
240
241 :type training_epochs: int
242 :param training_epochs: number of epochs used for training
243
244 :type dataset: string
245 :param dataset: path to the picked dataset
246
247 """
248 datasets = load_data(dataset)
249 train_set_x, train_set_y = datasets[0]
250
251 # compute number of minibatches for training, validation and testing
252 n_train_batches = train_set_x.get_value(borrow=True).shape[0] // batch_size
253
254 # allocate symbolic variables for the data
255 index = T.lscalar() # index to a [mini]batch
256 x = T.matrix('x') # the data is presented as rasterized images
257
258 if not os.path.isdir(output_folder):
259 os.makedirs(output_folder)
260 os.chdir(output_folder)
261 ####################################
262 # BUILDING THE MODEL #
263 ####################################
264
265 rng = numpy.random.RandomState(123)
266
267 ca = cA(numpy_rng=rng, input=x,
268 n_visible=28 * 28, n_hidden=500, n_batchsize=batch_size)
269
270 cost, updates = ca.get_cost_updates(contraction_level=contraction_level,
271 learning_rate=learning_rate)
272
273 train_ca = theano.function(
274 [index],
275 [T.mean(ca.L_rec), ca.L_jacob],
276 updates=updates,
277 givens={
278 x: train_set_x[index * batch_size: (index + 1) * batch_size]
279 }
280 )
281
282 start_time = timeit.default_timer()
283
284 ############
285 # TRAINING #
286 ############
287
288 # go through training epochs

Callers 1

cA.pyFile · 0.85

Calls 5

load_dataFunction · 0.90
tile_raster_imagesFunction · 0.90
cAClass · 0.85
saveMethod · 0.80
get_cost_updatesMethod · 0.45

Tested by

no test coverage detected