def _calc_elbo(vars, model, n_mcsamples, random_seed):
 theano.config.compute_test_value = 'ignore'
 shared = pm.make_shared_replacements(vars, model)
 factors = ([var.logpt for var in model.basic_RVs] + model.potentials)
 logpt = tt.add(*map(tt.sum, factors))
 ([logp], inarray) = pm.join_nonshared_inputs([logpt], vars, shared)
 uw = tt.vector('uw')
 uw.tag.test_value = floatX(np.concatenate([inarray.tag.test_value, inarray.tag.test_value]))
 elbo = _elbo_t(logp, uw, inarray, n_mcsamples, random_seed)
 return (elbo, shared)

def _calc_elbo ( vars , model , n_mcsamples , random_seed ) : theano . config . compute_test_value = 'ignore' shared = pm . make_shared_replacements ( vars , model ) factors = ( [ var . logpt for var in model . basic_RVs ] + model . potentials ) logpt = tt . add ( * map ( tt . sum , factors ) ) ( [ logp ] , inarray ) = pm . join_nonshared_inputs ( [ logpt ] , vars , shared ) uw = tt . vector ( 'uw' ) uw . tag . test_value = floatX ( np . concatenate ( [ inarray . tag . test_value , inarray . tag . test_value ] ) ) elbo = _elbo_t ( logp , uw , inarray , n_mcsamples , random_seed ) return ( elbo , shared )
calculate approximate elbo .