Ejemplo n.º 1
0
    def __call__(self, x, xmask=None):
        probs = self.d(x) * 0.98 + 0.01
        mask = srng.uniform(probs.shape) < probs
        print xmask
        mask.name = "mask!"
        masked = self.h.activation(sparse_dot(x, xmask, self.h.W, mask, self.h.b, self.block_size))
        if not "this is the equivalent computation in theano":
            h = self.h(x)
            if self.do_dropout:
                h = h * (srng.uniform(h.shape) < 0.5)
            h_r = h.reshape([h.shape[0], self.nblocks, self.block_size])
            masked = h_r * mask.dimshuffle(0,1,'x')
            masked = masked.reshape(h.shape)

        self.sample_probs = T.prod(mask*probs+(1-probs)*(1-mask), axis=1)
        self.probs = probs
        return masked, mask
Ejemplo n.º 2
0
    def __call__(self, x, xmask=None):
        probs = self.d(x) * 0.98 + 0.01
        mask = srng.uniform(probs.shape) < probs
        print xmask
        mask.name = "mask!"
        masked = self.h.activation(sparse_dot(x, xmask, self.h.W, mask, self.h.b, self.block_size))
        if not "this is the equivalent computation in theano":
            h = self.h(x)
            if self.do_dropout:
                h = h * (srng.uniform(h.shape) < 0.5)
            h_r = h.reshape([h.shape[0], self.nblocks, self.block_size])
            masked = h_r * mask.dimshuffle(0,1,'x')
            masked = masked.reshape(h.shape)

        self.sample_probs = T.prod(mask*probs+(1-probs)*(1-mask), axis=1)
        self.probs = probs
        return masked, mask
Ejemplo n.º 3
0
 def __call__(self, x, xmask=None):
     mask = srng.uniform((x.shape[0], self.nblocks)) < self.rate
     masked = self.h.activation(
         sparse_dot(x, xmask, self.h.W, mask, self.h.b, self.block_size))
     return masked, mask
Ejemplo n.º 4
0
 def __call__(self, x, xmask=None):
     mask = srng.uniform((x.shape[0],self.nblocks)) < self.rate
     masked = self.h.activation(sparse_dot(x, xmask, self.h.W, mask, self.h.b, self.block_size))
     return masked, mask