Probabilistic-Programming-and-Bayesian-Methods-for-Hackers icon indicating copy to clipboard operation
Probabilistic-Programming-and-Bayesian-Methods-for-Hackers copied to clipboard

Chapter 3 | creating Poisson data N>1 likelihood error | TFP version

Open Pindar777 opened this issue 6 years ago • 1 comments

Hi there, when trying to run the code with N>1 (introduction of part 3) these lines are not executed likelihood_x_ = evaluate(tfd.Poisson(rate=x_).prob(data_[:, 0])) likelihood_y_ = evaluate(tfd.Poisson(rate=y_).prob(data_[:, 1]))

Error message: ValueError: Dimensions must be equal, but are 10 and 100 for 'Poisson_20/prob/mul' (op: 'Mul') with input shapes: [10], [100].

Pindar777 avatar Jan 05 '19 12:01 Pindar777

For N>1 Replace the last three lines of code with:

likelihood_x_ = evaluate(tfd.Poisson(rate=x_).prob(data_[:, 0][:, np.newaxis]))
likelihood_y_ = evaluate(tfd.Poisson(rate=y_).prob(data_[:, 1][:, np.newaxis]))
L_ = evaluate(tf.matmul((likelihood_x_.T), (likelihood_y_)))

It'll work.

mmalekzadeh avatar May 23 '19 12:05 mmalekzadeh