Skip to content

Avoid unnecessary computation with generated_quantities #884

@tiemvanderdeure

Description

@tiemvanderdeure

generated_quantities always re-computes the entire model - even when not the entire model is needed to actually generate the returned values. E.g.

@model function complicated_model()
    a ~ Normal(0, 1)
    sleep(0.1) # some expensive computation
    b ~ Normal(0, 1)
    return a
end

chn = sample(complicated_model(), NUTS(0.65), 100)
generated_quantities(complicated_model(), chn)

What is the easiest way around this? Submodels don't work because the variables have different names - so I suppose the only way is to make a new model that doesn't have the unnecessary expensive bits?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions