greta-dev / greta

simple and scalable statistical modelling in R
https://greta-stats.org
Other
524 stars 63 forks source link

Do more in tensorflow instead of coming back to R repeatedly #547

Open njtierney opened 2 years ago

njtierney commented 2 years ago

For example, during warmup we step between R and TF every 4 iterations:

https://github.com/greta-dev/greta/blob/master/R/inference_class.R#L376

Using this code:

https://github.com/greta-dev/greta/blob/master/R/inference_class.R#L552-L622

However, in TF2, we can avoid doing this on the R side and do it completely in TF with. This would save us going back and forth between R and TF in the warmup phase, buying us some efficiency!

We can also explore tracking the progress bar in TF rather than from the R side every 50 iterations

njtierney commented 1 year ago

So we should replace the tuning algorithm that we use internally from within R, to instead use the TFP version:

https://www.tensorflow.org/probability/api_docs/python/tfp/mcmc/DualAveragingStepSizeAdaptation