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)
评论列表
文章目录