vae.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:theanomodels 作者: clinicalml 项目源码 文件源码
def _buildEmission(self, z, X, add_noise = False):
        """
                                Build subgraph to estimate conditional params
        """
        if add_noise:
            inp_p   = z + self.srng.normal(z.shape,0,0.0025,dtype=config.floatX)
        else:
            inp_p   = z
        for p_l in range(self.params['p_layers']):
            inp_p = self._LinearNL(self.tWeights['p_'+str(p_l)+'_W'], self.tWeights['p_'+str(p_l)+'_b'], inp_p)

        if self.params['data_type']=='real':
            mu_p    = self._LinearNL(self.tWeights['p_mu_W'],self.tWeights['p_mu_b'],inp_p, onlyLinear=True)
            logcov_p= self._LinearNL(self.tWeights['p_logcov_W'],self.tWeights['p_logcov_b'],inp_p, onlyLinear=True)
            negCLL_m= 0.5 * (np.log(2 * np.pi) + logcov_p + ((X - mu_p) / T.exp(0.5*logcov_p))**2)
            return (mu_p, logcov_p), negCLL_m.sum(1,keepdims=True)
        else:
            mean_p = T.nnet.sigmoid(self._LinearNL(self.tWeights['p_mean_W'],self.tWeights['p_mean_b'],inp_p,onlyLinear=True))
            negCLL_m = T.nnet.binary_crossentropy(mean_p,X)
            return (mean_p,), negCLL_m.sum(1,keepdims=True)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号