SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1904.04676 · 2019

Block Neural Autoregressive Flow

arXiv · PDF · Open in the Atlas

Code that ran

2 of 4 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 0 have no contract verdict; 2 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/1904.04676.json · badge: /api/ran/1904.04676.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
nicola-decao/BNAF canonical (classifier label)
classifier basis: classifier_2025
2 ran · 2 no recorded run
FunctionStatusWhere it lives
compute_log_p_x Ran
ran; our contract draft was wrong, not the code
nicola-decao/BNAF/toy2d.py
code served (permissive licence) · get_code("1e3e1419bbf70774")
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 SimpleFlowModel(nn.Module):
    """A minimal flow model that returns transformed samples and log jacobian diagonal."""
    
    def __init__(self, input_dim, output_dim):
        super().__init__()
        self.input_dim = input_dim
        self.output_dim = output_dim
        self.linear = nn.Linear(input_dim, output_dim)
        self.log_scale = nn.Parameter(torch.zeros(output_dim))
    
    def forward(self, x):
        """
        Args:
            x: input tensor of shape (batch_size, input_dim)
        
        Returns:
            y_mb: transformed output of shape (batch_size, output_dim)
            log_diag_j_mb: log determinant of jacobian diagonal of shape (batch_size,)
        """
        y_mb = self.linear(x)
        # Simulate a scaling transformation
        y_mb = y_mb * torch.exp(self.log_scale)
        # Log jacobian diagonal: sum of log scales (simplified for a diagonal jacobian)
        log_diag_j_mb = self.log_scale.sum().expand(x.shape[0])
        return y_mb, log_diag_j_mb

# Create model with distinct dimensions
batch_size = 2
input_dim = 4
output_dim = 3

model = SimpleFlowModel(input_dim, output_dim)

# Create input minibatch
x_mb = torch.randn(batch_size, input_dim)

ARGS = {
    "model": model,
    "x_mb": x_mb
}
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
save_model Ran
ran; our contract draft was wrong, not the code
nicola-decao/BNAF/density_estimation.py
code served (permissive licence) · get_code("c7c2cd135ec55792")
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 function. 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 torch.nn as nn
import os
import tempfile

torch.manual_seed(0)

# Create a small nn.Module
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

model = SimpleModel()

# Create an optimizer
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

# Create args object with required attributes
class Args:
    def __init__(self):
        self.save = True
        self.load = None
        self.path = tempfile.gettempdir()

args = Args()

# Define the ARGS dict
ARGS = {
    'model': model,
    'optimizer': optimizer,
    'epoch': 5,
    'args': args
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not 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
create_model Not yet run
unverified (harvested, no recorded run)
nicola-decao/BNAF/toy2d.py
code served (permissive licence) · get_code("f2977965fe47a3fe")
How it ran

no invocation recorded.

create_model Not yet run
unverified (harvested, no recorded run)
nicola-decao/BNAF/density_estimation.py
code served (permissive licence) · get_code("87c781818f839148")
How it ran

no invocation recorded.

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 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 4 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-23.

Repositories linked to this paper

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

Abstract

Normalising flows (NFS) map two density functions via a differentiable bijection whose Jacobian determinant can be computed efficiently. Recently, as an alternative to hand-crafted bijections, Huang et al. (2018) proposed neural autoregressive flow (NAF) which is a universal approximator for density functions. Their flow is a neural network (NN) whose parameters are predicted by another NN. The latter grows quadratically with the size of the former and thus an efficient technique for parametrization is needed. We propose block neural autoregressive flow (B-NAF), a much more compact universal approximator of density functions, where we model a bijection directly using a single feed-forward network. Invertibility is ensured by carefully designing each affine transformation with block matrices that make the flow autoregressive and (strictly) monotone. We compare B-NAF to NAF and other established flows on density estimation and approximate inference for latent variable models. Our proposed flow is competitive across datasets while using orders of magnitude fewer parameters.

For agents

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

get_harvested_code_for_paper("1904.04676")
get_code_for_paper("1904.04676")
have("1904.04676")

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

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

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

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

Connect an agent — have() is free.