Skip to content
プロジェクト

msainsburydale/NeuralEstimators.jl

GitHubで見る

概要

Julia package for simulation-based, likelihood-free parameter inference using neural networks.

システム・インフラ

この数値の測り方

計測したスター増加

24時間
0
7日間
+1
15日間
+1
1か月
+3

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

NeuralEstimators

CI codecov

NeuralEstimators is a Julia package for fast simulation-based inference using neural networks. It is designed for settings where likelihoods are intractable or classical methods such as MCMC are computationally expensive. The package supports:

  • Neural posterior estimation (NPE): directly learn the posterior distribution
  • Neural ratio estimation (NRE): approximate likelihood ratios for flexible frequentist or Bayesian inference
  • Neural Bayes estimation (NBE): efficiently estimate functionals (point summaries) of the posterior distribution

These methods are likelihood-free and amortized: once the neural networks are trained on simulated data, they enable rapid inference across arbitrarily many observed data sets orders of magnitude faster than conventional approaches.

See the documentation to get started.

Overview

graph LR

    %% --- Training phase ---
    subgraph Training["Offline training (one-time cost)"]
        A["Sample parameters\nθ ~ p(θ)"] --> B["Simulate data\nZ ~ p(Z | θ)"]
        B --> C["Train neural network"]
    end

    C --> NN(["Trained neural network"])

    %% --- Inference phase ---
    subgraph Inference["Online inference (fast)"]
        D["Observed data Zₒ"] --> NN
        NN --> E["Approximate posterior\np(θ | Zₒ)"]
    end

    %% --- Styling ---
    classDef process fill:#2d2d2d,stroke:#999,color:#fff;
    classDef data fill:#1f3b4d,stroke:#4aa3df,color:#fff;
    classDef model fill:#3b2d4d,stroke:#b388ff,color:#fff;

    class A,B,D,E data;
    class C process;
    class NN model;

Backends

The package supports neural networks defined with either of the two leading deep-learning packages in Julia, namely Flux.jl or Lux.jl.

Installation

Please first install the current stable release of Julia. Then, install the current stable version of the package using the following command inside Julia:

using Pkg; Pkg.add("NeuralEstimators")

Or install the current development version using the command:

using Pkg; Pkg.add(url = "https://github.com/msainsburydale/NeuralEstimators.jl")

Quick start

The following code constructs an NBE for parameters $\boldsymbol{\theta} \equiv (\mu, \sigma)'$ from data $\boldsymbol{Z} \equiv (Z_1, \dots, Z_n)'$, where each $Z_i \overset{\mathrm{iid}}\sim N(\mu, \sigma^2)$.

using NeuralEstimators
using Flux

# Dimension of θ and number of replicates
d, n = 2, 100  

# Functions to sample from prior p(θ) and simulate data p(Z|θ)
sampler(K) = NamedMatrix(μ = randn(K), σ = rand(K))
simulator(θ::AbstractVector) = θ["μ"] .+ θ["σ"] .* sort(randn(n))
simulator(θ::AbstractMatrix) = reduce(hcat, map(simulator, eachcol(θ)))

# Neural network, an MLP mapping n inputs into d outputs
network = Chain(Dense(n, 64, gelu), Dense(64, 64, gelu), Dense(64, d))

# Initialise an NBE
estimator = PointEstimator(network)

# Train the estimator
estimator = train(estimator, sampler, simulator)

# Apply to observed data
Z = simulator(sampler(1))  # stand-in for real observations
infer(estimator, Z)     # point estimate

R interface

A convenient interface for R users is available on CRAN.

Contributing

We welcome contributions of all sizes. To get started, see CONTRIBUTING.md for an overview of the code structure, development workflow, and how to submit contributions. A list of planned improvements is available in TODO.md, and instructions for contributing to the documentation can be found in docs/README.md.

If you encounter a bug or have a suggestion, please feel free to open an issue or submit a pull request.

Supporting and citing

This software was developed as part of academic research. If you would like to support it, please star the repository. If you use it in your research or other activities, please also use the following citation.

Expand for BibTeX
@misc{,
  title = {{NeuralEstimators.jl}: A {J}ulia package for efficient simulation-based inference using neural networks},
  author = {Sainsbury-Dale, Matthew},
  year = {2026},
  note = {Version x.x.x},
  howpublished = {\url{https://github.com/msainsburydale/NeuralEstimators.jl}}
}

@article{,
    title = {Likelihood-Free Parameter Estimation with Neural {B}ayes Estimators},
    author = {Matthew Sainsbury-Dale and Andrew Zammit-Mangion and Raphael Huser},
    journal = {The American Statistician},
    year = {2024},
    volume = {78},
    pages = {1--14},
    doi = {10.1080/00031305.2023.2249522},
  }

関連プロジェクトを探す

読み込み中…