Flow adaptation fits much worse when the posterior scale is small

未关闭
#367 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
python

调研方向

Start by running the included 50-dimensional normal example and compare fisher_distance and final step size at the two covariance scales. The payload does not name implementation files or tests, and says the cause is unknown, so trace how adaptation="flow" and with_transform_adapt handle scale changes. Done means the flow fits comparably at small and unit scales while sampling still recovers the target statistics.

由索引模型根据 Issue 内容生成。

描述

bug normalizing-flows

adaptation="flow" fits the flow much worse when the posterior's scale is small, even with x64 enabled. On a correlated 50-dimensional normal, the mean fisher distance is 0.025 at unit scale and 2090 after scaling the covariance by 1e-8, and the final step size drops from 1.62 to 0.066. Sampling still recovers the means and standard deviations to within about 15%, and the cause isn't established.

import jax

jax.config.update("jax_enable_x64", True)

import numpy as np
import pymc as pm

import nutpie

rng = np.random.default_rng(0)
dim = 50
factor = rng.normal(size=(dim, dim)) / np.sqrt(dim)
correlation = factor @ factor.T + 0.1 * np.eye(dim)

for scale in [1.0, 1e-4]:
    with pm.Model() as model:
        pm.MvNormal("x", mu=np.zeros(dim), cov=correlation * scale**2)

    compiled = nutpie.compile_pymc_model(model, backend="jax", gradient_backend="jax")
    trace = nutpie.sample(compiled.with_transform_adapt(num_layers=4), adaptation="flow",
                          chains=1, draws=500, seed=1, progress_bar=False)
    print(f"scale={scale:.0e}  fisher_distance={float(trace.sample_stats['fisher_distance'].mean()):.3f}")
# scale=1e+00  fisher_distance=0.025
# scale=1e-04  fisher_distance=2090.241
主要语言
Python
星标
214
派生
30
平均合并
3 小时 50 分钟
30 天内合并 PR
1

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pymc-devs/nutpie 的其他 Issue

查看 pymc-devs/nutpie 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。