changeset 318:8de3bef71458

Ajoute plus de fonctionnalite
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Fri, 02 Apr 2010 09:12:40 -0400
parents 067e747fd9c0
children 7a12d2c3d06b
files deep/stacked_dae/v_sylvain/nist_sda.py
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/deep/stacked_dae/v_sylvain/nist_sda.py	Thu Apr 01 20:09:14 2010 -0400
+++ b/deep/stacked_dae/v_sylvain/nist_sda.py	Fri Apr 02 09:12:40 2010 -0400
@@ -55,8 +55,18 @@
     n_outs = 62 # 10 digits, 26*2 (lower, capitals)
      
     examples_per_epoch = NIST_ALL_TRAIN_SIZE
+    
+    #To be sure variables will not be only in the if statement
+    PATH = ''
+    nom_reptrain = ''
+    nom_serie = ""
+    if state['pretrain_choice'] == 0:
+        nom_serie="series_NIST.h5"
+    elif state['pretrain_choice'] == 1:
+        nom_serie="series_P07.h5"
 
-    series = create_series(state.num_hidden_layers)
+    series = create_series(state.num_hidden_layers,nom_serie)
+
 
     print "Creating optimizer with state, ", state
 
@@ -127,21 +137,25 @@
         
         
     if finetune_choice==-1:
-        print('\nSERIE OF 3 DIFFERENT FINETUNINGS')
+        print('\nSERIE OF 4 DIFFERENT FINETUNINGS')
         print('\n\n\tfinetune with NIST\n\n')
+        sys.stdout.flush()
         optimizer.reload_parameters('params_pretrain.txt')
         optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1)
         channel.save()
         print('\n\n\tfinetune with P07\n\n')
+        sys.stdout.flush()
         optimizer.reload_parameters('params_pretrain.txt')
         optimizer.finetune(datasets.nist_P07(),datasets.nist_all(),max_finetune_epoch_P07,ind_test=0)
         channel.save()
         print('\n\n\tfinetune with NIST (done earlier) followed by P07 (written here)\n\n')
+        sys.stdout.flush()
         optimizer.reload_parameters('params_finetune_NIST.txt')
         optimizer.finetune(datasets.nist_P07(),datasets.nist_all(),max_finetune_epoch_P07,ind_test=20)
         channel.save()
         print('\n\n\tfinetune with NIST only on the logistic regression on top.\n\
         All hidden units output are input of the logistic regression\n\n')
+        sys.stdout.flush()
         optimizer.reload_parameters('params_pretrain.txt')
         optimizer.finetune(datasets.nist_all(),datasets.nist_P07(),max_finetune_epoch_NIST,ind_test=1,special=1)
         channel.save()
@@ -152,7 +166,7 @@
 
 # These Series objects are used to save various statistics
 # during the training.
-def create_series(num_hidden_layers):
+def create_series(num_hidden_layers, nom_serie):
 
     # Replace series we don't want to save with DummySeries, e.g.
     # series['training_error'] = DummySeries()
@@ -161,7 +175,7 @@
 
     basedir = os.getcwd()
 
-    h5f = tables.openFile(os.path.join(basedir, "series.h5"), "w")
+    h5f = tables.openFile(os.path.join(basedir, nom_serie), "w")
 
     # reconstruction
     reconstruction_base = \