diff deep/stacked_dae/v_sylvain/nist_sda.py @ 238:9fc641d7adda

Possibilite de restreindre la taille des ensemble d'entrainement, valid et test afin de pouvoir tester le code rapidement
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Mon, 15 Mar 2010 13:22:20 -0400
parents ecb69e17950b
children 6d49cf134a40
line wrap: on
line diff
--- a/deep/stacked_dae/v_sylvain/nist_sda.py	Mon Mar 15 10:09:50 2010 -0400
+++ b/deep/stacked_dae/v_sylvain/nist_sda.py	Mon Mar 15 13:22:20 2010 -0400
@@ -49,6 +49,7 @@
     REDUCE_TRAIN_TO = 1000
     MAX_FINETUNING_EPOCHS = 2
     REDUCE_EVERY = 10
+    MINIBATCH_SIZE=20
 
 # Possible values the hyperparameters can take. These are then
 # combined with produit_cartesien_jobs so we get a list of all
@@ -71,7 +72,7 @@
                        'hidden_layers_sizes':500,
                        'corruption_levels':0.2,
                        'minibatch_size':20,
-                       #'reduce_train_to':10000,
+                       'reduce_train_to':10000,
                        'num_hidden_layers':1})
 
 '''
@@ -94,16 +95,18 @@
 ##
 ##    print "NIST loaded"
 ##
-##    # For test runs, we don't want to use the whole dataset so
-##    # reduce it to fewer elements if asked to.
-##    rtt = None
-##    if state.has_key('reduce_train_to'):
-##        rtt = state['reduce_train_to']
-##    elif REDUCE_TRAIN_TO:
-##        rtt = REDUCE_TRAIN_TO
-##
-##    if rtt:
-##        print "Reducing training set to "+str(rtt)+ " examples"
+    # For test runs, we don't want to use the whole dataset so
+    # reduce it to fewer elements if asked to.
+    rtt = None
+    if state.has_key('reduce_train_to'):
+        rtt = int(state['reduce_train_to']/state['minibatch_size'])
+    elif REDUCE_TRAIN_TO:
+        rtt = int(REDUCE_TRAIN_TO/MINIBATCH_SIZE)
+
+    if rtt:
+        print "Reducing training set to "+str(rtt*state['minibatch_size'])+ " examples"
+    else:
+        rtt=float('inf')    #No reduction
 ##        nist.reduce_train_set(rtt)
 ##
 ##    train,valid,test = nist.get_tvt()
@@ -111,7 +114,7 @@
 
     n_ins = 32*32
     n_outs = 62 # 10 digits, 26*2 (lower, capitals)
-
+    
     series = create_series(state.num_hidden_layers)
 
     print "Creating optimizer with state, ", state
@@ -120,10 +123,10 @@
                                     n_ins=n_ins, n_outs=n_outs,\
                                     series=series)
 
-    optimizer.pretrain(datasets.nist_all)
+    optimizer.pretrain(datasets.nist_all,rtt)
     channel.save()
 
-    optimizer.finetune(datasets.nist_all)
+    optimizer.finetune(datasets.nist_all,rtt)
     channel.save()
 
     return channel.COMPLETE