Dear all,
Can someone explain to me that the n_adapts in case NUTS algorithm NUTS(n_adapts, δ) used in Turing sample function is number of iteration or number of accepted samples before main sampling? Because when I give n_adapts 100 and print out iterations completed in @model, I can see that main sampling still not started even when 100 iterations are completed. Im confused because I just checked quickly on Gemini and it says n_adapts is iteration not accepted samples before beginning of main sampling.
Thank you for your help.
I’m not sure if I totally understand the question here, but I’ll try my best to answer what I can.
n_adapts refers to the number of iterations (calls to AbstractMCMC.step) where we adaptively tune the Euclidean metric. Therefore, if you set n_adapts to 100, then the first 100 states along the Markov chain will be used to estimate the covariance.
By default these states are thrown away, but from what I’ve seen they are always accepted. If you want a better look at the states used in adaptation, feel free to add the discard_adapt kwarg to your sampler.
rng = MersenneTwister(1234)
chain = sample(rng, model, NUTS(100, 0.65), 250; discard_adapt=false)
describe(chain[101:end])
The first 100 elements of the chain are used in adaptation, and are usually discarded without the additional flag. If you were to exclude this flag, it would perform 350 iterations and return the last 250 elements.
Hope that helps
That also what I found out but then if I have following situation chain = sample(model, model, NUTS(100, 0.65), 250; discard_adapt=false)print iterations as follow inside @model where iteration_counter = Ref(0) outside of @model:
@model xyz(....)
# other stuff
if iteration_counter[] % 100 == 0
@info "$(iteration_counter[])"
end
end
model = xyz(....)
chain = sample(model, model, NUTS(100, 0.65), 250; discard_adapt=false)
when I get this @info it means 100 iterations are done right ? Because even after that I see sampling doesn’t start. why so? Am I missing something?
or may be better question, is there a way to track warmup ? if I give 1000 warmup then i can extract update 500 steps already done 500 remaining?