Skip to content

variational output shouldn't throw with when ADVI fails to converge #347

@bbbales2

Description

@bbbales2

Summary:

I ran a model with ADVI and got:

>>> fit = mod.variational()
INFO:cmdstanpy:start chain 1
INFO:cmdstanpy:finish chain 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bbales2/.local/lib/python3.8/site-packages/cmdstanpy/model.py", line 1079, in variational
    raise RuntimeError('The algorithm may not have converged.')
RuntimeError: The algorithm may not have converged.

ADVI will fail to converge a lot and the intermediate output is useful in figuring out what went wrong. This can be a warning but shouldn't be an error.

Model was:

parameters {
    real x1;
    vector[2] x2[2];
    real x3[2, 2, 2, 2];
}

model {
    x2[1] ~ normal(5, 1);
    x2[2] ~ normal(0, 1);
    x1 ~ normal(0, 1);
    to_array_1d(x3) ~ normal(0, 1);
}

generated quantities {
    int z1 = bernoulli_rng(0.5);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions