Needles in a haystack

Building on Models: Experiences from a Decade with the Microcircuit Model

KHK • Aachen • 3 April 2024

How machine learning falls short of learning mechanistic models, and what we can do about it

Alexandre René

Computational Network Science group (RWTH)

rene@cs.rwth-aachen.de

Concept vs Task oriented workflows

Usual scientific workflow

Anecdotal

observations

Usual scientific workflow

Usual mL workflow

Conceive theory

Conceive experiment

Accumulate data

Compare

Make prediction

New experiment?

Conceive task

experiment

Select architecture

Learn theory

Train model

Make prediction

Compare

New task?

Assumptions

Symmetry

Conservation

Exchangeability

Assumptions

Symmetry

Color invariance

Exchangeability

Anecdotal

observations

Anecdotal

observations

Validate/falsify

Validate/falsify

Accumulate data

(training data)

Accumulate more data

(test data)

Concept vs Task oriented workflows

Needles in a haystack

Optimize model

Falsification analysis

Part 1:

Learning with

domain-motivated constraints

 

domain-motivated constraints

Mesocircuit model

Inference constrained by a dynamical system

(René et al, Neural Comp, 2020)

  • Treat the dynamical system as a very complicated recurrent neural network (RNN).
  • Optimize parameters with backpropagation through time (BPTT).

Train output

\underbrace{\qquad\qquad}_{ \hspace{-200mu}\mathrlap{\begin{aligned} \quad \\[-2ex] \bar{n}^{(k)}_α &= \sum_{i=0}^{K-1} P^{(k)}_{λ,αi} \bar{m}^{(k)}_{αi} + P^{(k)}_{\mathrm{free},α}) x^{(k+1)}_α + P^{(k)}_{Λ,α} \left( N_α - \sum_{i=0}^{K-1} \bar{m}^{(k)}_{αi} - x^{(k)}_α \right) \\ a^{(k)}_α &= \frac{\bar{n}^{(k)}}{N_α Δt} \\ P^{(k)}_{Λ,α} &= \frac{\sum{K-1}_{i=0} P^{(k)}_{λ,αi} v^{(k)}_{αi} + P^{(k)}_{\mathrm{free}} z^{(k)}_α} {\sum_{i=0} v^{(k)}_{αi} + z^{(k)}_α} \\ x^{(k)}_α &= (1 - P^{(k)}_{\mathrm{free},α}) x^{(k+1)}_α + m^{(k)}_{αK} \\ &\;\vdots \end{aligned}} }

Mesoscopic model

Fit dynamics

(Schwalger, Deger & Gerstner, 2017)

(René et al, Neural Comp, 2020)

  • Treat the dynamical system as a very complicated recurrent neural network  (          ).
  • Optimize parameters with backpropagation through time               .

What we gain compared to a standard RNN:

  • Fewer parameters  (     )
  • Fewer redundancies between parameters
  • Robust training
  • Out-of-the-box generalization

So why don’t more people do this ?

  • Specifying the system is really hard.

Inference constrained by a dynamical system

RNN

(BPTT)

\(\color{#3cb100} Θ\)

\begin{aligned} &p({\color{#56ff00} Θ}) \\ &+ \log p\left({\color{#ff4e37} n(t_k)} | \mathcal{M}, {\color{#56ff00} Θ}, {\color{#ff4e37} n(t_{k-1})},{\color{#d39f4d} \{I(t)\}_t}\right) \\[2ex] &+ \log p\left({\color{#ff4e37} n(t_{k-1})} | \mathcal{M}, {\color{#56ff00} Θ}, {\color{#ff4e37} n(t_{k-2})}, {\color{#d39f4d} \{I(t)\}_t}\right) \\[2ex] &+ \dotsb \end{aligned}

\(\color{#3cb100} Θ\)

t_k
t_{k-1}
t_{k-2}

…

{\nabla}_{\color{3cb100} Θ}
p
w
\Delta
N
R
u_{\text{rest}}
\tau_{m}
u_{\mathrm{th}}
u_r
c
\Delta_u
\tau_s
J_\theta
\tau_\theta
t_{\mathrm{ref}}
\left(\begin{aligned} &p({\color{#3cb100} Θ}) \\ &+ \log p\left({\color{#ff4e37} n(t_k)} | \mathcal{M}, {\color{#3cb100} Θ}, {\color{#ff4e37} n(t_{k-1})},{\color{#d39f4d} \{I(t)\}_t}\right) \\[2ex] &+ \log p\left({\color{#ff4e37} n(t_{k-1})} | \mathcal{M}, {\color{#3cb100} Θ}, {\color{#ff4e37} n(t_{k-2})}, {\color{#d39f4d} \{I(t)\}_t}\right) \\[2ex] &+ \dotsb \end{aligned}\right)
\nabla_{\color{#3cb100} Θ}

Treat the mesoGIF model as an            and learn with
backpropagation through time                

RNN

(BPTT)

https://sinn-full.readthedocs.io/

Must implement entire model symbolically

Caveat:

Toolbox for making differentiable models

Complex constraints → Non-convex optimization

Fit dynamics

\underbrace{\qquad\qquad}_{ \hspace{-200mu}\mathrlap{\begin{aligned} \quad \\[-2ex] \bar{n}^{(k)}_α &= \sum_{i=0}^{K-1} P^{(k)}_{λ,αi} \bar{m}^{(k)}_{αi} + P^{(k)}_{\mathrm{free},α}) x^{(k+1)}_α + P^{(k)}_{Λ,α} \left( N_α - \sum_{i=0}^{K-1} \bar{m}^{(k)}_{αi} - x^{(k)}_α \right) \\ a^{(k)}_α &= \frac{\bar{n}^{(k)}}{N_α Δt} \\ P^{(k)}_{Λ,α} &= \frac{\sum{K-1}_{i=0} P^{(k)}_{λ,αi} v^{(k)}_{αi} + P^{(k)}_{\mathrm{free}} z^{(k)}_α} {\sum_{i=0} v^{(k)}_{αi} + z^{(k)}_α} \\ x^{(k)}_α &= (1 - P^{(k)}_{\mathrm{free},α}) x^{(k+1)}_α + m^{(k)}_{αK} \\ &\;\vdots \end{aligned}} }

Mesoscopic model

Many distinct Θ produce output consistent with data

Even worse case: dozens of plausible, distinct candidate models

Part 2:

Comparing candidate models

Small 2 neuron circuit

Needles in a haystack

Optimize model

Falsification analysis

Domain constraints

Still many plausible candidate models

Distinguishing candidate models

of the lobster pyloric circuit

Four candidate models for LP

(René & Longtin, in preparation)

expected risk (\(R\))

Model: Prinz et al, Similar network activity from disparate circuit parameters, 2004

What we were doing before

Is this difference meaningful ?

“Observed” data

Model

R_A = -\sum_t \log p\bigl(V(t) \mid t, I_{\mathrm{ext}}, \mathcal{M}_A \bigr)

Distinguishing candidate models

(René & Longtin, in preparation)

expected risk (\(R\))

Is this difference meaningful ?

This is a model selection problem

512 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
4096 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
32768 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
512 -0.72 -0.74 5.64
4096 0.64 -0.41 14.49
32768 -3.02 10.33 40.41
512 4×10⁻¹¹ 5×10⁻¹¹ 4×10⁻¹¹
4096 4×10⁻¹⁰ 4×10⁻¹⁰ 4×10⁻¹⁰
32768 1×10⁻⁹ 1×10⁻⁹ 1×10⁻⁹
512 0 0 0
4096 0 0 0
32768 0 0 0

Expected risk

Probability ratios

\( \log_{10} \left(\displaystyle \frac{\mathbb{P}(\text{model } A)}{\mathbb{P}(\text{model } B)}\right)\)

Likelihood ratio

Bayes factor

Bayesian expected risk

Noise strength →

Dataset size ↴  

\(\bf 2^{-12}\)

\(\bf 2^{-16}\)

\(\bf 2^{-20}\)

↓ Inconsistent values

→↓ Unreliable scale

↓ Inconsistent values

→ Unreliable scale

Prior-dependent

Data hungry

↓ Inconsistent values

→ Unreliable scale

Prior-dependent

Data hungry

↓ Convergences with size

Arbitrary scale

Distinguishing candidate models

expected risk (\(R\))

Is this difference meaningful ?

This is a model selection problem

…but the usual methods either

  • have no notion of scale
  • don’t converge as #samples increases
  • make strong but unreliable selections

(expected risk)

(likelihood, Bayes)

(likelihood)

We need

  • a way to quantify the strength of evidence
  • which converges as #samples increases
  • Reproducibility
  • Generalizability
  • Robustness against modelling errors

Distinguishing candidate models

expected risk (\(R\))

Is this difference meaningful ?

This is a model selection problem

We need

  • a way to quantify the strength of evidence
  • which converges as #samples increases
  • Reproducibility
  • Generalizability
  • Robustness against modelling errors

Ternary criterion

(three options)

Reported
strong evidence

\(\Rightarrow\)

Reported
weak evidence

\(\Rightarrow\)

Model selection outcome is robust

Inconsequential

(no model selected)

Distinguishing candidate models

We need

  • a way to quantify the strength of evidence
  • which converges as #samples increases

Observation:

Expected risk measures only aleatoric uncertainty.

(In-class errors)

Realization:

Neglecting epistemic uncertainty is what causes the likelihood to be overconfident.

(out-of-class / modelling errors)

Idea:

Epistemic uncertainty can quantify the strength of evidence

512 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
4096 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
32768 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
512 -0.72 -0.74 5.64
4096 0.64 -0.41 14.49
32768 -3.02 10.33 40.41
  • Robustness against modelling errors
  • Generalizability
  • Reproducibility

Expected risk

Likelihood ratio

Dataset size ↴  

\(\bf 2^{-12}\)

\(\bf 2^{-16}\)

\(\bf 2^{-20}\)

(Hüllermeier & Wagerman, 2021)

(Kiureghian & Ditlevsen, 2009)

↓ Inconsistent values

→↓ Unreliable scale

↓ Convergences with size

Arbitrary scale

(René & Longtin, in preparation)

Estimating epistemic (out-of-class) error

by comparing data and theory distributions

Evaluate two percent-point functions \(q\) (PPF, aka quantile function, aka inverse CDF).

  • The mixed PPF evaluates the model loss on the true samples.
  • The synthetic PPF evaluates the model loss on simulated model samples.

The difference between the two PPFs we call the empirical model discrepancy: \(δ^{\mathrm{EMD}}\).

The “real” PPF should be somewhere between these curves.

We sample PPFs such that their variance is proportional to \(δ^{\mathrm{EMD}}\).

Each PPF

Distribution of PPFs ⇒ Distribution of expected risks \(R\)

⇒ Different expected risk \(R\)

-\log p\bigl(V(t) \mid t, I_{\mathrm{ext}}, \mathcal{M}_A \bigr)

(René & Longtin, in preparation)

Epistemic uncertainty as distribution of expected risk

PPF samples

expected risk (\(R\))

quantile

\(Φ\)

Reported
strong evidence

\(\Rightarrow\)

Reported
weak evidence

\(\Rightarrow\)

Model selection outcome is robust

Inconsequential

(no model selected)

(René & Longtin, in preparation)

Epistemic uncertainty as distribution of expected risk

We interpret \(R\)-distributions as follows:

  • Aleatoric uncertainty ⇒ location
  • Epistemic uncertainty ⇒ scale

PPF samples

expected risk distribution (\(R\))

Reported
strong evidence

\(\Rightarrow\)

Reported
weak evidence

\(\Rightarrow\)

Model selection outcome is robust

Inconsequential

(no model selected)

quantile

\(Φ\)

B^{\mathrm{EMD}}_{AB;c} := P(R_A < R_B\mid c)

Probability ratios – \(\displaystyle \frac{\mathbb{P}(\text{model } A)}{\mathbb{P}(\text{model } B)}\)

EMD-criterion is more consistent

then previously shown criteria

(René & Longtin, in preparation)

512 -0.09 0.06 0.44
4096 -0.04 0.10 0.62
32768 0.02 -0.05 0.32
512 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
4096 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
32768 2×10⁻⁵ -5×10⁻⁴ 5×10⁻³
512 -0.72 -0.74 5.64
4096 0.64 -0.41 14.49
32768 -3.02 10.33 40.41
512 4×10⁻¹¹ 4×10⁻¹¹ 4×10⁻¹¹
4096 4×10⁻¹⁰
4×10⁻¹⁰
4×10⁻¹⁰
32768 1×10⁻⁹
1×10⁻⁹
1×10⁻⁹
0
0
0

0
0
0

0
0
0

Expected risk

Likelihood ratio

Bayes factor

Bayesian expected risk

Noise strength →

Dataset size ↴  

↓ Inconsistent values

→↓ Unreliable scale

↓ Inconsistent values

→ Unreliable scale

Prior-dependent

Data hungry

↓ Inconsistent values

→ Unreliable scale

Prior-dependent

Data hungry

\(\bf 2^{-12}\)

\(\bf 2^{-16}\)

\(\bf 2^{-20}\)

EMD criterion

↓ Convergences with size

Arbitrary scale

↓ Convergences with size

Scale adjusted by epistemic uncertainty

EMD-falsification available in a Python toolbox

(René & Longtin, in preparation)

from emd_falsify import Bemd, make_empirical_risk

synth_ppfA = make_empirical_risk(lossA(modelA.generate(Lsynth)))
synth_ppfB = make_empirical_risk(lossB(modelB.generate(Lsynth)))
mixed_ppfA = make_empirical_risk(lossA(data))
mixed_ppfB = make_empirical_risk(lossB(data))

Bemd(mixed_ppfA, mixed_ppfB, synth_ppfA, synth_ppfB, c=c)
\begin{align*} L_{\mathrm{synth}} \in \mathbb{N} &: \text{\# points to simulate} \\ \mathtt{modelA}/\mathtt{B} &: \text{candidate models to compare} \\ \mathtt{data} &: \text{actual observed data} \\ c \in \mathbb{R}_+ &: \text{sensitivity parameter} \end{align*}

Summary

Optimize model

Falsification analysis

Domain constraints

Aleatoric uncertainty

≠

Epistemic uncertainty

Collaborators

Neurophysics group (Ottawa)

Machine learning in science group (Tübingen)

Institute for Advanced Simulation (IAS-6), Computational and Systems Neuroscience (Jülich)

Computational Network Science group (Aachen)

  • Claudia Merger
  • Sandra Nestler
  • Prof. Moritz Helias
  • Peter Bouss
  • Kirsten Fischer
  • Prof. André Longtin
  • Prof. Jakob Macke
  • Prof. Michael Schaub
  • Bastian Epping
  • Josef Hoppe

Resources

Model falsification paper

(pre-pre-print)

Model falsification toolbox

(emd-falsify on PyPI)

Mesoscopic inference

(René et al., 2020,

Neural Comp.)

Pyloric circuit simulator

(Python+JAX, GitHub)

Model inference toolbox

(Python+Theano, GitHub)

EXTRAS

(René et al, Neural Comp, 2020)

Inference constrained by a dynamical system

EXTRA: Recovery of effective parameters for out-of-class (heterogeneous populations)

Empirical CDF and PPF

Aleatoric sources of variability

Distribution of the per-sample loss

Bootstrap estimate for the uncertainty of the expected risk

Two models of blackbody radiation

\mathcal{B}_{\mathrm{RJ}}(\lambda ; T) = \frac{2 c k_B T}{\lambda ^4}
\mathcal{B}_\mathrm{P}(\lambda ; T) = \frac{2 h c^2}{\lambda ^5} \frac{1}{\exp\left( \frac{hc}{\lambda k_B T} \right) - 1}
\begin{aligned} \mathcal{B} \mid \lambda , T &\sim {s}\mathop{\mathrm{Poisson}}\bigl(\mathcal{B}_{\mathrm{P}}(\lambda ; T) / s\bigr) + \mathcal{B}_0 \,, \end{aligned}

Radiance

Wavelength (μm)

Wavelength (μm)

Rayleigh-Jeans model

Planck model

No measurement is perfect, so we also simulate noise:

(René & Longtin, in preparation)

(René & Longtin, in preparation)

Epistemic uncertainty as distribution of expected risk

Each PPF

Distribution of PPF ⇒ Distribution of expected risks \(R\)

⇒ Different expected risk \(R\)

 

  • Aleatoric error ⇒ position
  • Epistemic error ⇒ spread

Reduce noise

(René & Longtin, in preparation)

EXTRA: Calibrating the stochastic quantile process

Inferring the mesoGIF model with
backpropagation through time (BPTT)

  • Models can have dozens of parameters
    • Parameter sweeps would be prohibitive
  • BPTT is typically used to train RNNs
  • Models can be viewed as complicated RNNs
\argmax \bigl[\, p\left({\color{#56ff00} Θ} | \mathcal{M}, {\color{#ff4e37} \{u(t)\}_t}, {\color{#d39f4d} \{I(t)\}_t} \right) \bigr]
\begin{aligned} \argmax \bigl[ &\log p({\color{#56ff00} Θ}) \\ &+ \log p\left({\color{#ff4e37} u(t_k)} | \mathcal{M}, {\color{#56ff00} Θ}, {\color{#ff4e37} u(t_{k-1})},{\color{#d39f4d} \{I(t)\}_t}\right) \\ &+ \log p\left({\color{#ff4e37} u(t_{k-1})} | \mathcal{M}, {\color{#56ff00} Θ}, {\color{#ff4e37} u(t_{k-2})}, {\color{#d39f4d} \{I(t)\}_t}\right) \\ &+ \dotsb \bigr] \end{aligned}

Baye's theorem
+ Markov property

\({\color{#ff4e37} u(t_{k-1})} + Δt \cdot\! \left.\frac{d {\color{#ff4e37} u}}{dt}\right\rvert_{{\color{#d39f4d} Θ}, {\color{#56ff00} I}}\)

\({\color{#56ff00} Θ}\)

\(\mathcal{M}\)

\({\color{#ff4e37} u(t)}\)

\({\color{#d39f4d} I(t)}\)

Model; \(\left.\frac{d {\color{#ff4e37} u}}{dt}\right\rvert_{{\color{#56ff00} Θ}, {\color{#d39f4d} I}}\)

Model parameters

Observations

Inputs

BPTT looks for:

Parameters of the mesoscopic model

René et al. (2020)

A(t)
Parameter No. components Description
connection probability
connection weight
transmission delay
no. of neurons in pop
membrane resistance
membrane resting potential
membrane time constant
absolute refractory period
non-adapting threshold
reset potential
escape rate at threshold
noise level
synaptic time constant
adaptation strength
adaptation time constant
p
w
\Delta
N
R
u_{\text{rest}}
\tau_{m}
u_{\mathrm{th}}
u_r
c
\Delta_u
\tau_s
J_\theta
\tau_\theta
t_{\mathrm{ref}}
M^2
M^2
M^2
M
M
M
M
M
M
M
M
M
M/2
M / 2
M

models the average population activity

models spiking of each individual neurons

mesoGIF:

GIF:

(Schwalger et al., 2017)

(Gerstner et al., 2014)

\begin{aligned} \tau_{m,\alpha} \frac{d{\color{#6190ff}u_i}}{dt} &= -{\color{#6190ff}u} + u_{\text{rest}} + R {\color{#d39f4d} I(t)} \\ {\color{#ff4e37} s_i(t)} &\sim \text{Bernouilli} \bigl( c \exp\left({\color{#6190ff} u(t)} - \vartheta_i(t)\right) \Delta t \bigr) \end{aligned}

GIF:

mesoGIF:

s(t)

Homogeneous

A(t)
Parameter No. components Description
connection probability
connection weight
transmission delay
no. of neurons in pop
membrane resistance
membrane resting potential
membrane time constant
absolute refractory period
non-adapting threshold
reset potential
escape rate at threshold
noise level
synaptic time constant
adaptation strength
adaptation time constant
p
w
\Delta
N
R
u_{\text{rest}}
\tau_{m}
u_{\mathrm{th}}
u_r
c
\Delta_u
\tau_s
J_\theta
\tau_\theta
t_{\mathrm{ref}}
M^2
M^2
M^2
M
M
M
M
M
M
M
M
M
M/2
M / 2
M

models the average population activity

models spiking of each individual neurons

mesoGIF:

GIF:

(Schwalger et al., 2017)

(Gerstner et al., 2014)

mesoGIF:

s(t)

Homogeneous

\(\color{#3cb100} Θ\)

\begin{aligned} \log p\left({\color{#ff4e37} n(t_k)} | \mathcal{M}, {\color{#56ff00} Θ}, {\color{#ff4e37} n(t_{k-1})},{\color{#d39f4d} \{I(t)\}_t}\right) \end{aligned}

Parameters of the mesoscopic model

Inferring the mesoGIF model

2 populations,
14 parameters to infer

Train

Test

Input

Output – true

Optimizer
iterations

Input

Output – pop E – model vs true

Not shown:
Also demonstrated with 4 populations, 36 parameters

(              )

Pop. E

Pop. I

René et al. (Neural Computation, 2020)

Results for the mesoGIF model

Inference finds effective parameters which compensate for incorrect model assumptions

René et al. (Neural Computation, 2020)

Heterogeneous parameters

GIF (true model)

mesoGIF (homogeneous model) –
Theoretical params

mesoGIF (homogeneous model) –
Inferred params

MCMC sampling with the mesoGIF model

A differentiable likelihood can also be used for MCMC sampling

→credible intervals (Bayesian error bars) on the parameters

(Marginals from the 14-D distribution)

René et al. (Neural Computation, 2020)