Changing prior during inference

Is it possible to change the prior (or the parameters of the prior) during the inference?

I tried defining the prior with the shared variable as shown below.

shared_mu = shared(np.ones(d))
shared_sd = shared(np.ones(d))
w = pm.Normal(‘w’, mu=shared_mu, sd=shared_sd, shape=d)

Then I get an error saying that TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Can someone please help me to change the prior of the model during the inference?


you can, the error you are seeing is a bug, see workaround here: Normal distribution throws errors when using shared variables

1 Like