Help with Poisson distribution


Hi I am not able to find useful code example for Poisson distribution.

I did this based on sample code for Bernoulli

lambda = Normal(loc=tf.zeros([]), scale=0.6 * tf.ones([]))
N_lambda = tf.fill([FLAGS.N, FLAGS.T], (lambda)

y = Poisson(rate=N_lambda)

qlambda_loc = tf.get_variable("qlambda_loc", [])
qlambda_scale = tf.nn.softplus(tf.get_variable("qlambda_scale", []))
qlambda = Normal(loc=qlambda_loc, scale=qlambda_scale)

but this has a problem of not guaranteeing lambda is positive. what corrections do I need to define lambda and qlambda? and how to specify its positive?


I fixed it with
N_lambda2 = tf.fill([FLAGS.N, FLAGS.T], tf.exp(lambda_tilda2))

is there any thing else for improving this?