Esempio n. 1
0
    def sample_markov_chains(self,beta,step):
        cp.prod(self.h,self.w,self.v,'t','n')
        cp.matrix_plus_col(self.h,self.bias_hi)
        cp.apply_scalar_functor(self.h,cp.scalar_functor.MULT,beta)
        cp.apply_scalar_functor(self.h,cp.scalar_functor.SIGM)
        cp.rnd_binarize(self.h)
        cp.prod(self.v,self.w,self.h,'n','n')
        cp.matrix_plus_col(self.v,self.bias_lo)
        cp.apply_scalar_functor(self.v,cp.scalar_functor.MULT,beta)
        cp.apply_scalar_functor(self.baserate_bias,cp.scalar_functor.MULT,1-beta)

        cp.matrix_plus_col(self.v,self.baserate_bias)
        cp.apply_scalar_functor(self.baserate_bias,cp.scalar_functor.MULT,1.0/(1-beta))
        cp.apply_scalar_functor(self.v,cp.scalar_functor.SIGM)
        #if step % 100 == 0:
           #plt.figure(1)
           #self.v_=self.v.np
           #showthis = self.v_.copy()
           #plt.matshow(showthis[:,0].reshape((28,28)))
           #plt.draw()
           #if not os.path.exists("/tmp/%s"%os.getlogin()):
               #os.mkdir("/tmp/%s"%os.getlogin())
           #plt.savefig("/tmp/%s/chain_%05d.png"%(os.getlogin(),step))
        cp.rnd_binarize(self.v)
Esempio n. 2
0
File: base.py Progetto: 0rchard/CUV
 def sample(self):
     if self.unit_type ==  UnitType.gaussian or self.unit_type ==  UnitType.cont:
         cp.add_rnd_normal(self.act)
     elif self.unit_type ==  UnitType.binary:
         cp.rnd_binarize(self.act)
Esempio n. 3
0
 def sample(self):
     if self.unit_type == UnitType.gaussian or self.unit_type == UnitType.cont:
         cp.add_rnd_normal(self.act)
     elif self.unit_type == UnitType.binary:
         cp.rnd_binarize(self.act)