Flow adaptation fits much worse when the posterior scale is small

Aperta
#367 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
214
Fork
30
Merge medio
3h 50m
PR unite (30g)
1

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di pymc-devs/nutpie

Tutte le issue di pymc-devs/nutpie

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.