Dynamic change model graph structure in the runtime

Because recently I have worked involving auto-drive field and started use GTSAM (using Factor Graphs and Bayes Networks as the underlying computing paradigm). It can be changed graph framework (Continuous to add factor node into whole graph) in runtime. All models I have read are fixed structure with static deep network structure to fit real data pattern by learning parameters. IMO, pyro model can also be viewed as factor graph with additional deep neural network node. So I am curious to know whether pyro has ability to dynamic adjust its model structure in the runtime (might be keep neural network node structure unchange and adjust should occur after parameters completing one-step learning)?
This behavior has potential application, like self-adaption for complex and pattern changed problems (smooth or sudden change type).

Hi @sejabs, yes, if I correctly understand your question, Pyro does allow dynamic model structure; this is the “universal” in “deep universal probabilistic programming”. If you’ve written a dynamic model in Pyro, then you can perform inference by either (1) writing a corresponding guide that always follows the same model structure, or (2) using an autoguide that is compatible with dynamic model structure, such as AutoNormalMessenger.

Thanks @fritzo , I will try to write a test example.