# HG changeset patch # User Xavier Glorot # Date 1247518591 14400 # Node ID 4e70f509ec012a8cd936474876a0a5c0e711a3a1 # Parent 961dc1a7921b95711185fa9715e1fa1d774d22f0 check saturation and noiseseed methods for DAA input groups diff -r 961dc1a7921b -r 4e70f509ec01 pylearn/algorithms/sandbox/DAA_inputs_groups.py --- 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)