changeset 350:625c0c3fcbdb

Amelioration de l'efficacite de la sauvegarde des parametres
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Tue, 20 Apr 2010 16:38:13 -0400
parents 22efb4968054
children 799ad23a161f
files deep/stacked_dae/v_sylvain/sgd_optimization.py
diffstat 1 files changed, 10 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/deep/stacked_dae/v_sylvain/sgd_optimization.py	Mon Apr 19 10:12:17 2010 -0400
+++ b/deep/stacked_dae/v_sylvain/sgd_optimization.py	Tue Apr 20 16:38:13 2010 -0400
@@ -9,7 +9,8 @@
 import datetime
 import theano.tensor as T
 import sys
-import pickle
+#import pickle
+import cPickle
 
 from jobman import DD
 import jobman, jobman.sql
@@ -141,7 +142,7 @@
         #To be able to load them later for tests on finetune
         self.parameters_pre=[copy(x.value) for x in self.classifier.params]
         f = open('params_pretrain.txt', 'w')
-        pickle.dump(self.parameters_pre,f)
+        cPickle.dump(self.parameters_pre,f,protocol=-1)
         f.close()
 
 
@@ -295,8 +296,8 @@
                     break
             
             if decrease == 1:
-		if (ind_test == 21 & epoch % 100 == 0) | ind_test == 20:
-			learning_rate /= 2 #divide the learning rate by 2 for each new epoch of P07 (or 100 of NIST)
+                if (ind_test == 21 & epoch % 100 == 0) | ind_test == 20:
+                    learning_rate /= 2 #divide the learning rate by 2 for each new epoch of P07 (or 100 of NIST)
             
             self.series['params'].append((epoch,), self.classifier.all_params)
 
@@ -322,23 +323,23 @@
         
         if special == 1:    #To keep a track of the value of the parameters
             f = open('params_finetune_stanford.txt', 'w')
-            pickle.dump(parameters_finetune,f)
+            cPickle.dump(parameters_finetune,f,protocol=-1)
             f.close()
         
         elif ind_test == 0 | ind_test == 20:    #To keep a track of the value of the parameters
             f = open('params_finetune_P07.txt', 'w')
-            pickle.dump(parameters_finetune,f)
+            cPickle.dump(parameters_finetune,f,protocol=-1)
             f.close()
                
 
         elif ind_test== 1:    #For the run with 2 finetunes. It will be faster.
             f = open('params_finetune_NIST.txt', 'w')
-            pickle.dump(parameters_finetune,f)
+            cPickle.dump(parameters_finetune,f,protocol=-1)
             f.close()
         
         elif ind_test== 21:    #To keep a track of the value of the parameters
             f = open('params_finetune_P07_then_NIST.txt', 'w')
-            pickle.dump(parameters_finetune,f)
+            cPickle.dump(parameters_finetune,f,protocol=-1)
             f.close()
         
 
@@ -347,7 +348,7 @@
         
         #self.parameters_pre=pickle.load('params_pretrain.txt')
         f = open(which)
-        self.parameters_pre=pickle.load(f)
+        self.parameters_pre=cPickle.load(f)
         f.close()
         for idx,x in enumerate(self.parameters_pre):
             if x.dtype=='float64':