changeset 793:4e70f509ec01

check saturation and noiseseed methods for DAA input groups
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Mon, 13 Jul 2009 16:56:31 -0400
parents 961dc1a7921b
children 951272679910
files pylearn/algorithms/sandbox/DAA_inputs_groups.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/sandbox/DAA_inputs_groups.py	Fri Jul 10 18:14:36 2009 -0400
+++ b/pylearn/algorithms/sandbox/DAA_inputs_groups.py	Mon Jul 13 16:56:31 2009 -0400
@@ -16,13 +16,13 @@
 # saving loading utils--------------------------------------------
 def save_mat(fname, mat, save_dir=''):
     assert isinstance(mat, numpy.ndarray)
-    print 'save ndarray to file: ', fname
+    print 'save ndarray to file: ', save_dir + fname
     file_handle = open(os.path.join(save_dir, fname), 'w')
     filetensor.write(file_handle, mat)
     file_handle.close()
 
 def load_mat(fname, save_dir=''):
-    print 'loading ndarray from file: ', fname
+    print 'loading ndarray from file: ', save_dir + fname
     file_handle = open(os.path.join(save_dir,fname), 'r')
     rval = filetensor.read(file_handle)
     file_handle.close()
@@ -715,7 +715,7 @@
         i=i+1
         save_mat('wenc%s.ft'%(i) ,inst.daaig[i].w, save_dir)
         save_mat('benc%s.ft'%(i) ,inst.daaig[i].b, save_dir)
-
+    
     def _instance_load(self,inst,save_dir='',coef = None, Sup_layer = None):
         
         if coef is None:
@@ -747,4 +747,12 @@
         else:
             inst.daaig[i].w = load_mat('wenc%s.ft'%(Sup_layer),save_dir)
             inst.daaig[i].b = load_mat('benc%s.ft'%(Sup_layer),save_dir)
+    
+    def _instance_checksaturation(self,inst,layer,inputs):
+        return numpy.mean(numpy.median(abs(inst.representation[layer](*inputs)),1))
+    
+    def _instance_noiseseed(self,inst,seed):
+        scannoise.R.rand.seed(seed)
+        for i in range(self.depth):
+            inst.daaig[i].random.seed(seed+i+1)