Flow adaptation fits much worse when the posterior scale is small

Abierto
#367 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Python
Estrellas
214
Forks
30
Merge medio
3 h 50 min
PR fusionados (30 d)
1

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de pymc-devs/nutpie

Todos los issues de pymc-devs/nutpie

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.