I have implemented a simple case from “Bayesian Methods for Hackers” about the number of received messages.
Data was generated with the next parameters: size=100, Poisson1(20), Poisson2(50), and switch=70 day.
Estimations:
can you please explain where do I use .long() and why is it a problem? Maybe you can add a link to the documentation.
As you might see HMC works well. The issue is only the SVI estimation of the switch point.
you are trying to turn a continuous latent variable (tau) into an integer. this is a non-differentiable operation.
it may be that HMC is giving you results that are plausible in this particular case. however in order for HMC to generate samples that are actually (approximate) samples from the posterior, the log density of the model must be sufficiently smooth. if it is not, arbitrarily strange things may happen.
Understand, thank you for your clarification. What to do in such cases? The superpower of Pyro is Universality:… Random Control Flow. I suppose every if/else statement will create non-differentiable operation?
it depends on the particular case. it’s hard to generalize because the space of all possible models is very large. in some cases discrete structure can be enumerated. in other cases reweighted wake sleepinference is a possibility. the list goes on…
i don’t know the exact details of your modeling goal but i’d probably encode the switch as a discrete latent variable and enumerate it out using TraceEnum_ELBO
I have tried to enumerate it using TraceEnum_ELBO but it does not work. As a result, when_to_switch values are all the same.
I want to make it work as parallel. What is wrong with this code?