如何保存/还原AdaptiveMetropolis步骤方法状态?

2024-04-16 14:32:20 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经运行了一些相当昂贵的模式与一个漫长的磨合时间。我想保存和恢复AdaptiveMetropolis步骤方法的状态(至少)以减少老化时间。有没有一个推荐的方法可以做到这一点,或者我应该只是pickle step_method.current_state()dict并尝试更新step_method.Cstep_method.proposal_sd,或者在我想重新启动时从pickle数据中更新其他dict?你知道吗

(来自不推荐的googlegroup论坛的交叉帖子:https://groups.google.com/forum/#!topic/pymc/6U72WuuXmMo


Tags: 方法状态step时间模式步骤currentmethod
1条回答
网友
1楼 · 发布于 2024-04-16 14:32:20

你试过使用save_staterestore_sampler_state方法吗?它们应该使用任何非sqlite后端(例如pickle、txt)。前者应将采样器信息保存到数据库中;下面是一个示例:

    {'stochastics': {'alpha': array([-0.20073951]), 'beta': array([ 2.77634734])}, 'step_methods': {'AdaptiveMetropolis_beta_alpha': {'C': array([[ 41.28628017,   2.79567393],
       [  2.79567393,   1.8832875 ]]), '_trace': [array([ 10.4010084 ,   1.48321645]), ... [ 0.43509455,  1.30152996]]), 
       'accepted': 69.0, 'shrink_if_necessary': False}}, 
       'sampler': {'status': 'ready', '_iter': 2000, '_tune_interval': 1000, '_tuned_count': 0, '_tune_throughout': True, '_burn_till_tuned': False, '_current_iter': 2000, '_burn': 0, '_thin': 1}}

相关问题 更多 >