Hi,
I want to investigate the divergence of my model, so I relied on the nice tutorial about this topic: Diagnosing Biased Inference with Divergences
After running my model with 2 chains, PyMC3 indicates me that 6 divergences were detected for the first chain, and 9 for the second one, which makes a total number of 15 divergences.
However, the number of divergence that I can recover using trace['diverging']
is 9. So I guess it returns the number of divergence of the second chain only. Why is that? Is there a way to recover the divergences of the first chain? Or do I misunderstand something?
Furthermore, when I use the code from Diagnosing Biased Inference with Divergences to recover the divergent points with:
divergent_point = defaultdict(list)
chain_warn = trace.report._chain_warnings
for i in range(len(chain_warn)):
for warning_ in chain_warn[i]:
if warning_.step is not None and warning_.extra is not None:
for RV in model.free_RVs:
para_name = RV.name
divergent_point[para_name].append(warning_.extra[para_name])
for RV in model.free_RVs:
para_name = RV.name
divergent_point[para_name] = np.asarray(divergent_point[para_name])
I recover 12 divergent points. Again, I would have expected 15, or at least 9 or 6. Is it a normal behaviour?
Thanks for the help!