Turing.jl icon indicating copy to clipboard operation
Turing.jl copied to clipboard

Sampler initialization (`init_params`)

Open mateuszbaran opened this issue 4 years ago • 2 comments
trafficstars

Hi! Could you add some documentation to sampler initialization (init_params)? Right now it's quite non-intuitive to use.

I'm currently using the NUTS sampler for my model and unfortunately it tends to pick initial values of random variables that are far from the expected ones, and my model has numerical issues at such extreme values. Thus I'd like to start with some more likely initial values.

mateuszbaran avatar Mar 29 '21 18:03 mateuszbaran

I'm not even sure how to use init_params, I tried that:

@model function test(x)
    a ~ Normal(1.0, 2.0)
    println(a)
    x ~ filldist(Normal(a, 0.1), length(x))
    return a
end

sample(test([1.0, 2.0, 1.3]), NUTS(), 10; init_params = [3.1])

and it never goes through a equal to 3.1 (that value is never printed).

mateuszbaran avatar Mar 29 '21 19:03 mateuszbaran

After some investigation it looks like this line: https://github.com/TuringLang/DynamicPPL.jl/blob/3602c56dba16bc2b60efbef6bf6ff31226354c7d/src/sampler.jl#L80 resets initialization for HMC samplers (but not for MH).

mateuszbaran avatar Mar 30 '21 17:03 mateuszbaran

Likely fixed by https://github.com/TuringLang/DynamicPPL.jl/pull/232

yebai avatar Nov 14 '22 13:11 yebai