SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2002.06707 · 2020

Stochastic Normalizing Flows

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-21; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2002.06707.json · badge: /api/ran/2002.06707.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
noegroup/stochastic_normalizing_flows canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
prepare_image Ran
ran on a synthesized input
noegroup/stochastic_normalizing_flows/snf_code/snf_code/image.py
code served (permissive licence) · get_code("5b1a9cf0842aab9f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a small RGB image (height=10, width=8, channels=3)
rgb = np.random.randint(0, 256, (10, 8, 3), dtype=np.uint8)

# Define crop as [y1, y2, x1, x2]
crop = [1, 8, 1, 7]

# Define embed as [height, width]
embed = [12, 10]

# Define other parameters
white_cutoff = 225
gauss_sigma = 5
background = 0.01

ARGS = {
    "rgb": rgb,
    "crop": crop,
    "embed": embed,
    "white_cutoff": white_cutoff,
    "gauss_sigma": gauss_sigma,
    "background": background,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sample_bg_histogram Ran
ran on a synthesized input
noegroup/stochastic_normalizing_flows/snf_code/snf_code/imagetools.py
code served (permissive licence) · get_code("7af2b13628f6b4d0")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (50, 50) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class MockPrior:
    def sample(self, nsamples):
        return torch.randn(nsamples, 4)

class MockFlow(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def forward(self, z):
        y = self.linear(z)
        return y, None

class MockBG:
    def __init__(self):
        self.prior = MockPrior()
        self.flow = MockFlow()

bg = MockBG()

ARGS = {
    'bg': bg,
    'nsamples': 100000,
    'nbins': 50,
    'xrange': (-1, 1),
    'yrange': (-1, 1)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (50, 50) — shape (50, 50) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
sample_energy Ran
ran on a synthesized input
noegroup/stochastic_normalizing_flows/snf_code/snf_code/analysis.py
code served (permissive licence) · get_code("f16fdd2af62521f2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
import torch.nn as nn

torch.manual_seed(0)

class SimplePrior(nn.Module):
    def __init__(self, dim=4):
        super().__init__()
        self.dim = dim
    
    def sample(self, n_samples, temperature=1.0):
        return torch.randn(n_samples, self.dim)
    
    def energy(self, z):
        return torch.sum(z**2, dim=1, keepdim=True)

class SimpleTarget(nn.Module):
    def __init__(self, dim=4):
        super().__init__()
        self.dim = dim
    
    def energy(self, y):
        return torch.sum((y - 1.0)**2, dim=1, keepdim=True)

class SimpleFlow(nn.Module):
    def __init__(self, dim=4):
        super().__init__()
        self.dim = dim
    
    def forward(self, z, temperature=1.0):
        y = z + torch.randn_like(z) * 0.1
        dW = torch.zeros(z.shape[0], 1)
        return y, dW

class BridgeFlow(nn.Module):
    def __init__(self, dim=4):
        super().__init__()
        self.dim = dim
        self.prior = SimplePrior(dim)
        self._prior = SimplePrior(dim)
        self._target = SimpleTarget(dim)
        self.flow_model = SimpleFlow(dim)
    
    def flow(self, z, temperature=1.0):
        y, dW = self.flow_model(z, temperature)
        return y, dW

bg = BridgeFlow(dim=4)

ARGS = {
    'bg': bg,
    'n_samples': 2,
    'n_repeat': 2,
    'nbins': 50
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
statistical_efficiency Ran
ran on a synthesized input
noegroup/stochastic_normalizing_flows/snf_code/snf_code/analysis.py
code served (permissive licence) · get_code("20a354810e79e29f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np
import torch.nn as nn

torch.manual_seed(0)

class StandInEnergy(nn.Module):
    def forward(self, x):
        # x shape: (batch, dim)
        # return shape: (batch, 1)
        return torch.sum(x ** 2, dim=1, keepdim=True)

class StandInPrior(nn.Module):
    def __init__(self, dim=4):
        super().__init__()
        self.dim = dim
    
    def sample(self, n_samples, temperature=1.0):
        # return shape: (n_samples, dim)
        return torch.randn(n_samples, self.dim) * temperature
    
    def energy(self, z):
        # z shape: (batch, dim)
        # return shape: (batch, 1)
        return torch.sum(z ** 2, dim=1, keepdim=True)

class StandInTarget(nn.Module):
    def __init__(self, dim=4):
        super().__init__()
        self.dim = dim
    
    def energy(self, y):
        # y shape: (batch, dim)
        # return shape: (batch, 1)
        return torch.sum((y - 1.0) ** 2, dim=1, keepdim=True)

class StandInBG(nn.Module):
    def __init__(self, dim=4):
        super().__init__()
        self._prior = StandInPrior(dim)
        self._target = StandInTarget(dim)
    
    def flow(self, z, temperature=1.0):
        # z shape: (batch, dim)
        # return y shape: (batch, dim), dW shape: (batch, 1)
        batch_size = z.shape[0]
        y = z + torch.randn_like(z) * 0.1
        dW = torch.randn(batch_size, 1)
        return y, dW

bg = StandInBG(dim=4)

ARGS = {
    'bg': bg,
    'n_samples': 20000,
    'n_resample': 100
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unnormalized_kl_div Ran
ran on a synthesized input
noegroup/stochastic_normalizing_flows/bgtorch/bgtorch/bg.py
code served (permissive licence) · get_code("4c47027dfade7db2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (2,) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class Prior(nn.Module):
    def __init__(self):
        super().__init__()
    
    def sample(self, n_samples, temperature=None):
        return torch.randn(n_samples, 4)

class Flow(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, z, temperature=None):
        x = self.linear(z)
        dlogp = torch.zeros(z.shape[0])
        return x, dlogp

class Target(nn.Module):
    def __init__(self):
        super().__init__()
    
    def energy(self, x, temperature=None):
        return torch.sum(x ** 2, dim=1)

prior = Prior()
flow = Flow()
target = Target()
n_samples = 2
temperature = None

ARGS = {
    "prior": prior,
    "flow": flow,
    "target": target,
    "n_samples": n_samples,
    "temperature": temperature
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unormalized_nll Ran
ran on a synthesized input
noegroup/stochastic_normalizing_flows/bgtorch/bgtorch/bg.py
code served (permissive licence) · get_code("72227dbc057d84e7")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 2, dtype family float, shape (2, 1) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleFlow(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x, inverse=False, temperature=None):
        # Returns (z, dlogp)
        z = self.linear(x)
        dlogp = torch.ones(x.shape[0], 1)
        return z, dlogp

class SimplePrior(nn.Module):
    def __init__(self):
        super().__init__()
    
    def energy(self, z, temperature=None):
        # Returns energy for each sample
        return torch.sum(z ** 2, dim=1, keepdim=True)

prior = SimplePrior()
flow = SimpleFlow()
x = torch.randn(2, 4)

ARGS = {
    "prior": prior,
    "flow": flow,
    "x": x,
    "temperature": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float, shape (2, 1) — shape (2, 1) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
ModelEval Not yet run
unverified (harvested, no recorded run)
noegroup/stochastic_normalizing_flows/flow_models.py
code served (permissive licence) · get_code("8ff2c04c57b4106f")
How it ran

no invocation recorded.

log_weights Not yet run
unverified (harvested, no recorded run)
noegroup/stochastic_normalizing_flows/bgtorch/bgtorch/bg.py
code served (permissive licence) · get_code("00c82805e8638ada")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-21.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

The sampling of probability distributions specified up to a normalization constant is an important problem in both machine learning and statistical mechanics. While classical stochastic sampling methods such as Markov Chain Monte Carlo (MCMC) or Langevin Dynamics (LD) can suffer from slow mixing times there is a growing interest in using normalizing flows in order to learn the transformation of a simple prior distribution to the given target distribution. Here we propose a generalized and combined approach to sample target densities: Stochastic Normalizing Flows (SNF) -- an arbitrary sequence of deterministic invertible functions and stochastic sampling blocks. We show that stochasticity overcomes expressivity limitations of normalizing flows resulting from the invertibility constraint, whereas trainable transformations between sampling steps improve efficiency of pure MCMC/LD along the flow. By invoking ideas from non-equilibrium statistical mechanics we derive an efficient training procedure by which both the sampler's and the flow's parameters can be optimized end-to-end, and by which we can compute exact importance weights without having to marginalize out the randomness of the stochastic blocks. We illustrate the representational power, sampling efficiency and asymptotic correctness of SNFs on several benchmarks including applications to sampling molecular systems in equilibrium.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2002.06707")
get_code_for_paper("2002.06707")
have("2002.06707")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2002.06707.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2002.06707.svg)](https://syntology.ai/paper/2002.06707)

Connect an agent — have() is free.