Beispiel #1
0
        tf.reduce_sum(variation_prior.log_prob(tf.cast(variation,
                                                       tf.float32))), floatX)
    ld = variation_d.logdens(variation)
    tf.add_to_collection('logdensities', ld[tf.newaxis])
    tf.add_to_collection('priors', pp)

    tf.summary.histogram('variation', variation)
    tf.summary.scalar('mean_variation', tf.reduce_mean(variation))

global_inf = DFlow([
    NVPFlow(dim=(VAR_DIM * 2 + 1) * VAR_DIM,
            name='flow_{}'.format(i),
            aux_vars=variation[tf.newaxis]) for i in range(6)
],
                   init_sigma=0.01)
global_prior = Normal(None, sigma=1.).logdens(global_inf.output)
tf.add_to_collection('priors', global_prior)
tf.add_to_collection('logdensities', global_inf.logdens)

individ_variation_prior = Normal((VAR_DIM * 2 + 1) * VAR_DIM,
                                 sigma=variation,
                                 mu=global_inf.output[0])

models = []
indivs = {}

with tf.variable_scope(tf.get_variable_scope(),
                       dtype=floatX,
                       reuse=tf.AUTO_REUSE):
    for country, data in country_data.items():
        with tf.variable_scope(country):