def decode(self, hiddens): """ Map inputs through the encoder function. Parameters ---------- hiddens : tensor_like or list of tensor_likes Theano symbolic (or list thereof) representing the input minibatch(es) to be encoded. Assumed to be 2-tensors, with the first dimension indexing training examples and the second indexing data dimensions. Returns ------- decoded : tensor_like or list of tensor_like Theano symbolic (or list thereof) representing the corresponding minibatch(es) after decoding. """ if self.act_dec is None: act_dec = lambda x: x else: act_dec = self.act_dec if isinstance(hiddens, tensor.Variable): X = act_dec(self.visbias + tensor.dot(hiddens, self.w_prime)) else: X = [self.decode(v) for v in hiddens] g = T.dvector() for i in range(self.N): start = i * 21 end = start + 20 indexis = numpy.arange(start, end + 1) if i == 0: g = rescaled_softmax(theano.tensor.subtensor.take( X, indexis, axis=1, mode='raise'), min_val=1e-5) else: g = T.concatenate([ g, rescaled_softmax(theano.tensor.subtensor.take( X, indexis, axis=1, mode='raise'), min_val=1e-5) ], axis=1) return g
def _corrupt(self, x): noise = self.s_rng.normal(size=x.shape, avg=0., std=self.corruption_level, dtype=theano.config.floatX) return rescaled_softmax(x + noise)
def _corrupt(self, x): noise = self.s_rng.normal( size=x.shape, avg=0., std=self.corruption_level, dtype=theano.config.floatX ) return rescaled_softmax(x + noise)
def decode(self, hiddens): """ Map inputs through the encoder function. Parameters ---------- hiddens : tensor_like or list of tensor_likes Theano symbolic (or list thereof) representing the input minibatch(es) to be encoded. Assumed to be 2-tensors, with the first dimension indexing training examples and the second indexing data dimensions. Returns ------- decoded : tensor_like or list of tensor_like Theano symbolic (or list thereof) representing the corresponding minibatch(es) after decoding. """ if self.act_dec is None: act_dec = lambda x: x else: act_dec = self.act_dec if isinstance(hiddens, tensor.Variable): X = act_dec(self.visbias + tensor.dot(hiddens, self.w_prime)) else: X= [self.decode(v) for v in hiddens] g = T.dvector() for i in range(self.N): start = i * 21 end = start + 20 indexis = numpy.arange(start,end+1) if i==0: g = rescaled_softmax(theano.tensor.subtensor.take(X,indexis,axis=1,mode='raise'),min_val=1e-5) else: g =T.concatenate([g,rescaled_softmax(theano.tensor.subtensor.take(X,indexis,axis=1,mode='raise'),min_val=1e-5)],axis=1) return g
def _corrupt(self, x): """ Corrupts a single tensor_like object. Parameters ---------- x : tensor_like Theano symbolic representing a (mini)batch of inputs to be corrupted, with the first dimension indexing training examples and the second indexing data dimensions. Returns ------- corrupted : tensor_like Theano symbolic representing the corresponding corrupted input. """ noise = self.s_rng.normal(size=x.shape, avg=0.0, std=self.corruption_level, dtype=theano.config.floatX) return rescaled_softmax(x + noise)
def _corrupt(self, x): """ Corrupts a single tensor_like object. Parameters ---------- x : tensor_like Theano symbolic representing a (mini)batch of inputs to be corrupted, with the first dimension indexing training examples and the second indexing data dimensions. Returns ------- corrupted : tensor_like Theano symbolic representing the corresponding corrupted input. """ noise = self.s_rng.normal(size=x.shape, avg=0., std=self.corruption_level, dtype=theano.config.floatX) return rescaled_softmax(x + noise)