SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1705.07057 · 2017

Masked Autoregressive Flow for Density Estimation

George Papamakarios, Iain Murray, Theo Pavlakou

arXiv · PDF · Open in the Atlas

Code that ran

22 of 28 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (14 of them constructed an object rather than computing a result; 2 honoured the contract we drafted, 0 violated it and 20 have no contract verdict; 0 failures of our instrument; 6 no recorded run), measured 2026-11-22; 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/1705.07057.json · badge: /api/ran/1705.07057.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
mahkons/flows community
Papers with Code archive
4 ran · 2 no recorded run
e-hulten/real-nvp-2d community
Papers with Code archive
4 ran · 2 no recorded run
e-hulten/maf community
Papers with Code archive
4 ran · 1 no recorded run
lifeitech/fce-2d community
Papers with Code archive
2 ran · 1 no recorded run
ricokaloklo/denmarf community
Papers with Code archive
2 ran · 0 no recorded run
CW-Huang/CP-Flow community
Papers with Code archive
2 ran · 0 no recorded run
kmzzhang/nbi community
Papers with Code archive
2 ran · 0 no recorded run
ikostrikov/pytorch-flows community
Papers with Code archive
1 ran · 0 no recorded run
GinGinWang/MTQ community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
ActNorm Ran
ran on a synthesized input · constructed an object; no result was computed
mahkons/flows/MAF/MAF.py
code served (permissive licence) · get_code("1497a8b2b937dd04")
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 an instance of its own class, ActNorm: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

# ActNorm.__init__ takes one parameter: dim
# From the code, we can see:
# - self.mean is a parameter of shape (dim,)
# - self.log_s is a parameter of shape (dim,)
# - forward_flow and inverse_flow use x which should be a tensor
# - data_init uses x.mean(dim=(0,)) and torch.var(x, dim=0)
#   suggesting x has shape (batch_size, dim)

dim = 4

ARGS = {
    'dim': dim
}
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 ActNorm — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a ActNorm 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
BatchNorm Ran
ran on a synthesized input · constructed an object; no result was computed
e-hulten/real-nvp-2d/new_model.py
pointer only (licence: NONE) · get_code("f3945dba0b2f2a01")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, e-hulten/real-nvp-2d when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

BatchNormLayer Ran
ran on a synthesized input · constructed an object; no result was computed
e-hulten/maf/maf.py
code served (permissive licence) · get_code("14efe965c1aa68ec")
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 an instance of its own class, BatchNormLayer: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

ARGS = {
    "dim": 4,
    "eps": 1e-05,
}
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 BatchNormLayer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BatchNormLayer 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
MADE Ran
ran on a synthesized input · constructed an object; no result was computed
e-hulten/maf/maf.py
code served (permissive licence) · get_code("ab526ee358bb52cd")
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 an instance of its own class, MADE: the run constructed the object and did not call it, so no result was computed. 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
from torch import Tensor
import numpy as np

torch.manual_seed(0)
np.random.seed(0)

ARGS = {
    "n_in": 4,
    "hidden_dims": [8, 6],
    "gaussian": False,
    "random_order": False,
    "seed": 42,
}
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 MADE — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MADE 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
MADE Ran
ran on a synthesized input
ricokaloklo/denmarf/denmarf/flows.py
code served (permissive licence) · get_code("b73e2b4f0815b899")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 torch.nn as nn

# The class uses nn.MaskedLinear which doesn't exist in standard PyTorch
# We need to create a stand-in implementation
class MaskedLinear(nn.Module):
    def __init__(self, in_features, out_features, mask, cond_in_features=None):
        super(MaskedLinear, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.cond_in_features = cond_in_features
        
        self.weight = nn.Parameter(torch.Tensor(out_features, in_features))
        self.bias = nn.Parameter(torch.Tensor(out_features))
        self.register_buffer('mask', mask)
        
        if cond_in_features is not None:
            self.cond_weight = nn.Parameter(torch.Tensor(out_features, cond_in_features))
        else:
            self.cond_weight = None
        
        nn.init.xavier_uniform_(self.weight)
        nn.init.zeros_(self.bias)
        if self.cond_weight is not None:
            nn.init.xavier_uniform_(self.cond_weight)
    
    def forward(self, inputs, cond_inputs=None):
        self.weight.data *= self.mask
        out = torch.nn.functional.linear(inputs, self.weight, self.bias)
        if cond_inputs is not None and self.cond_weight is not None:
            out = out + torch.nn.functional.linear(cond_inputs, self.cond_weight)
        return out

# Monkey-patch nn.MaskedLinear
nn.MaskedLinear = MaskedLinear

def get_mask(in_features, out_features, in_flow_features, mask_type=None):
    """
    mask_type: input | None | output
    
    See Figure 1 for a better illustration:
    https://arxiv.org/pdf/1502.03509.pdf
    """
    if mask_type == 'input':
        in_degrees = torch.arange(in_features) % in_flow_features
    else:
        in_degrees = torch.arange(in_features) % (in_flow_features - 1)
    if mask_type == 'output':
        out_degrees = torch.arange(out_features) % in_flow_features - 1
    else:
        out_degrees = torch.arange(out_features) % (in_flow_features - 1)
    return (out_degrees.unsqueeze(-1) >= in_degrees.unsqueeze(0)).float()

class MADE(nn.Module):
    """ An implementation of MADE
    (https://arxiv.org/abs/1502.03509).
    """

    def __init__(self, num_inputs, num_hidden, num_cond_inputs=None, act='relu', pre_exp_tanh=False):
        super(MADE, self).__init__()
        activations = {'relu': nn.ReLU, 'sigmoid': nn.Sigmoid, 'tanh': nn.Tanh}
        act_func = activations[act]
        input_mask = get_mask(num_inputs, num_hidden, num_inputs, mask_type='input')
        hidden_mask = get_mask(num_hidden, num_hidden, num_inputs)
        output_mask = get_mask(num_hidden, num_inputs * 2, num_inputs, mask_type='output')
        self.joiner = nn.MaskedLinear(num_inputs, num_hidden, input_mask, num_cond_inputs)
        self.trunk = nn.Sequential(act_func(), nn.MaskedLinear(num_hidden, num_hidden, hidden_mask), act_func(), nn.MaskedLinear(num_hidden, num_inputs * 2, output_mask))

    def forward(self, inputs, cond_inputs=None, mode='direct'):
        if mode == 'direct':
            h = self.joiner(inputs, cond_inputs)
            m, a = self.trunk(h).chunk(2, 1)
            u = (inputs - m) * torch.exp(-a)
            return (u, -a.sum(-1, keepdim=True))
        else:
            x = torch.zeros_like(inputs)
            for i_col in range(inputs.shape[1]):
                h = self.joiner(x, cond_inputs)
                m, a = self.trunk(h).chunk(2, 1)
                x[:, i_col] = inputs[:, i_col] * torch.exp(a[:, i_col]) + m[:, i_col]
            return (x, a.sum(-1, keepdim=True))


INIT_ARGS = {
    'num_inputs': 4,
    'num_hidden': 8,
    'num_cond_inputs': 3,
    'act': 'relu',
    'pre_exp_tanh': False,
}

ARGS = {
    'inputs': torch.randn(2, 4),
    'cond_inputs': torch.randn(2, 3),
    'mode': 'direct',
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
MADE Ran
ran on a synthesized input · constructed an object; no result was computed
e-hulten/real-nvp-2d/new_model.py
pointer only (licence: NONE) · get_code("dbff5eb0c83199fc")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, e-hulten/real-nvp-2d when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MADE Ran
ran on a synthesized input · constructed an object; no result was computed
CW-Huang/CP-Flow/lib/made.py
code served (permissive licence) · get_code("e6a14474e4b3485e")
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 an instance of its own class, MADE: the run constructed the object and did not call it, so no result was computed. 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 numpy as np
import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'nin': 4,
    'hidden_sizes': [8, 8],
    'nout': 8,
    'num_masks': 1,
    'natural_ordering': False,
    'activation': nn.ReLU()
}
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 MADE — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MADE 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
MADE Ran
ran on a synthesized input · constructed an object; no result was computed
ikostrikov/pytorch-flows/flows.py
code served (permissive licence) · get_code("098df5efa3c71254")
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 an instance of its own class, MADE: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

# First, we need to define nn.MaskedLinear since it's used in MADE but not provided
class MaskedLinear(nn.Module):
    def __init__(self, in_features, out_features, mask, num_cond_inputs=None):
        super(MaskedLinear, self).__init__()
        self.linear = nn.Linear(in_features, out_features)
        self.register_buffer('mask', mask)
        self.num_cond_inputs = num_cond_inputs
    
    def forward(self, inputs, cond_inputs=None):
        return self.linear(inputs)

# Monkey-patch nn.MaskedLinear for the MADE class to use
nn.MaskedLinear = MaskedLinear

# Now construct arguments for MADE
ARGS = {
    'num_inputs': 4,
    'num_hidden': 8,
    'num_cond_inputs': None,
    'act': 'relu',
    'pre_exp_tanh': False,
}
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 MADE — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MADE 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
MADE Ran
ran on a synthesized input · constructed an object; no result was computed
mahkons/flows/MAF/MAF.py
code served (permissive licence) · get_code("24daef5e3d4459b5")
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 an instance of its own class, MADE: the run constructed the object and did not call it, so no result was computed. 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 math

torch.manual_seed(0)

# Parameters for MADE.__init__
dim = 4
condition_dim = 3
hidden_dim = 6

ARGS = {
    'dim': dim,
    'condition_dim': condition_dim,
    'hidden_dim': hidden_dim,
}
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 MADE — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MADE 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
MADE Ran
ran on a synthesized input
GinGinWang/MTQ/models/flow_maf_models.py
pointer only (licence: NONE) · get_code("3ac8705b7982d1bf")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GinGinWang/MTQ when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MADE Ran
ran on a synthesized input
kmzzhang/nbi/src/nbi/nn/flows.py
pointer only (licence: NOASSERTION) · get_code("0f142b06e06b1de6")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, kmzzhang/nbi (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MADE Ran
ran on a synthesized input
lifeitech/fce-2d/flows/maf.py
code served (permissive licence) · get_code("cd73e59d4d2cfa4c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 torch.nn as nn
import math

# INIT_ARGS for MADE.__init__
INIT_ARGS = {
    'input_size': 5,
    'hidden_size': 8,
    'n_hidden': 2,
    'cond_label_size': 3,
    'activation': 'relu',
    'input_order': 'sequential',
    'input_degrees': None
}

# ARGS for MADE.forward
ARGS = {
    'x': torch.randn(2, 5),  # batch_size=2, input_size=5
    'y': torch.randn(2, 3)   # batch_size=2, cond_label_size=3
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
MAFLayer Ran
ran on a synthesized input · constructed an object; no result was computed
e-hulten/maf/maf.py
code served (permissive licence) · get_code("7e4b7180e009cb0b")
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 an instance of its own class, MAFLayer: the run constructed the object and did not call it, so no result was computed. 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
from typing import List

torch.manual_seed(0)

class MaskedLinear(nn.Linear):
    """Linear transformation with masked out elements. y = x.dot(mask*W.T) + b"""

    def __init__(self, n_in: int, n_out: int, bias: bool=True) -> None:
        super().__init__(n_in, n_out, bias)
        self.mask = None

    def initialise_mask(self, mask: torch.Tensor):
        """Internal method to initialise mask."""
        self.mask = mask

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        """Apply masked linear transformation."""
        import torch.nn.functional as F
        return F.linear(x, self.mask * self.weight, self.bias)


class MADE(nn.Module):

    def __init__(self, n_in: int, hidden_dims: List[int], gaussian: bool=False, random_order: bool=False, seed=None) -> None:
        super().__init__()
        import numpy as np
        from numpy.random import permutation, randint
        
        np.random.seed(seed)
        self.n_in = n_in
        self.n_out = 2 * n_in if gaussian else n_in
        self.hidden_dims = hidden_dims
        self.random_order = random_order
        self.gaussian = gaussian
        self.masks = {}
        self.mask_matrix = []
        self.layers = []
        dim_list = [self.n_in, *hidden_dims, self.n_out]
        for i in range(len(dim_list) - 2):
            self.layers.append(MaskedLinear(dim_list[i], dim_list[i + 1]))
            self.layers.append(nn.ReLU())
        self.layers.append(MaskedLinear(dim_list[-2], dim_list[-1]))
        self.model = nn.Sequential(*self.layers)
        self._create_masks()

    def forward(self, x: torch.Tensor) -> torch.Tensor:
        """Forward pass."""
        if self.gaussian:
            return self.model(x)
        else:
            return torch.sigmoid(self.model(x))

    def _create_masks(self) -> None:
        """Create masks for the hidden layers."""
        import numpy as np
        from numpy.random import permutation, randint
        
        L = len(self.hidden_dims)
        D = self.n_in
        self.masks[0] = permutation(D) if self.random_order else np.arange(D)
        for l in range(L):
            low = self.masks[l].min()
            size = self.hidden_dims[l]
            self.masks[l + 1] = randint(low=low, high=D - 1, size=size)
        self.masks[L + 1] = self.masks[0]
        for i in range(len(self.masks) - 1):
            m = self.masks[i]
            m_next = self.masks[i + 1]
            M = torch.zeros(len(m_next), len(m))
            for j in range(len(m_next)):
                M[j, :] = torch.from_numpy((m_next[j] >= m).astype(int))
            self.mask_matrix.append(M)
        if self.gaussian:
            m = self.mask_matrix.pop(-1)
            self.mask_matrix.append(torch.cat((m, m), dim=0))
        mask_iter = iter(self.mask_matrix)
        for module in self.model.modules():
            if isinstance(module, MaskedLinear):
                module.initialise_mask(next(mask_iter))


class MAFLayer(nn.Module):

    def __init__(self, dim: int, hidden_dims: List[int], reverse: bool):
        super(MAFLayer, self).__init__()
        self.dim = dim
        self.made = MADE(dim, hidden_dims, gaussian=True, seed=None)
        self.reverse = reverse

    def forward(self, x: torch.Tensor):
        out = self.made(x.float())
        mu, logp = torch.chunk(out, 2, dim=1)
        u = (x - mu) * torch.exp(0.5 * logp)
        u = u.flip(dims=(1,)) if self.reverse else u
        log_det = 0.5 * torch.sum(logp, dim=1)
        return (u, log_det)

    def backward(self, u: torch.Tensor):
        u = u.flip(dims=(1,)) if self.reverse else u
        x = torch.zeros_like(u)
        for dim in range(self.dim):
            out = self.made(x)
            mu, logp = torch.chunk(out, 2, dim=1)
            mod_logp = torch.clamp(-0.5 * logp, max=10)
            x[:, dim] = mu[:, dim] + u[:, dim] * torch.exp(mod_logp[:, dim])
        log_det = torch.sum(mod_logp, axis=1)
        return (x, log_det)


ARGS = {
    "dim": 4,
    "hidden_dims": [8, 8],
    "reverse": False,
}
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 MAFLayer — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MAFLayer 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
MaskedLinear Ran
ran on a synthesized input · constructed an object; no result was computed
e-hulten/maf/maf.py
code served (permissive licence) · get_code("00a0f4545a20f827")
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 an instance of its own class, MaskedLinear: the run constructed the object and did not call it, so no result was computed. 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
from torch import Tensor

torch.manual_seed(0)

# Create a MaskedLinear instance to test
n_in = 4
n_out = 3
bias = True

masked_linear = nn.Module()

# Create the actual MaskedLinear module
class MaskedLinear(nn.Linear):
    """Linear transformation with masked out elements. y = x.dot(mask*W.T) + b"""

    def __init__(self, n_in: int, n_out: int, bias: bool=True) -> None:
        """
        Args:
            n_in: Size of each input sample.
            n_out:Size of each output sample.
            bias: Whether to include additive bias. Default: True.
        """
        super().__init__(n_in, n_out, bias)
        self.mask = None

    def initialise_mask(self, mask: Tensor):
        """Internal method to initialise mask."""
        self.mask = mask

    def forward(self, x: Tensor) -> Tensor:
        """Apply masked linear transformation."""
        from torch.nn import functional as F
        return F.linear(x, self.mask * self.weight, self.bias)

# Instantiate the module
masked_linear = MaskedLinear(n_in=n_in, n_out=n_out, bias=bias)

# Create a mask tensor with same shape as weight (n_out, n_in)
mask = torch.ones(n_out, n_in)
masked_linear.initialise_mask(mask)

# Create input tensor (batch_size=2, features=4)
x = torch.randn(2, n_in)

# Execute forward pass
output = masked_linear(x)

ARGS = {
    "n_in": n_in,
    "n_out": n_out,
    "bias": bias
}
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 MaskedLinear — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MaskedLinear 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
MaskedLinear Ran
ran on a synthesized input · constructed an object; no result was computed
CW-Huang/CP-Flow/lib/made.py
code served (permissive licence) · get_code("f44d760efdbdbe0c")
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 an instance of its own class, MaskedLinear: the run constructed the object and did not call it, so no result was computed. 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 numpy as np

torch.manual_seed(0)

ARGS = {
    'in_features': 4,
    'out_features': 3,
    'bias': True
}
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 MaskedLinear — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MaskedLinear 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
MaskedLinear Ran
ran on a synthesized input · constructed an object; no result was computed
mahkons/flows/MAF/MAF.py
code served (permissive licence) · get_code("cae870109a352c71")
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 an instance of its own class, MaskedLinear: the run constructed the object and did not call it, so no result was computed. 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 math

torch.manual_seed(0)

in_sz = 4
out_sz = 3
mask = torch.randint(0, 2, (out_sz, in_sz)).float()

ARGS = {
    'in_sz': in_sz,
    'out_sz': out_sz,
    'mask': mask
}
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 MaskedLinear — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a MaskedLinear 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
MaskedLinear Ran
ran on a synthesized input
lifeitech/fce-2d/flows/maf.py
code served (permissive licence) · get_code("80e4b97aaed77a6c")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 3) 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 math
import torch
import torch.nn as nn
import torch.nn.functional as F

class MaskedLinear(nn.Linear):
    """ MADE building block layer """

    def __init__(self, input_size, n_outputs, mask, cond_label_size=None):
        super().__init__(input_size, n_outputs)
        self.register_buffer('mask', mask)
        self.cond_label_size = cond_label_size
        if cond_label_size is not None:
            self.cond_weight = nn.Parameter(torch.rand(n_outputs, cond_label_size) / math.sqrt(cond_label_size))

    def forward(self, x, y=None):
        out = F.linear(x, self.weight * self.mask, self.bias)
        if y is not None:
            out = out + F.linear(y, self.cond_weight)
        return out

    def extra_repr(self):
        return 'in_features={}, out_features={}, bias={}'.format(self.in_features, self.out_features, self.bias is not None) + (self.cond_label_size != None) * ', cond_features={}'.format(self.cond_label_size)


input_size = 4
n_outputs = 3
cond_label_size = 5

mask = torch.randint(0, 2, (n_outputs, input_size)).float()

INIT_ARGS = {
    'input_size': input_size,
    'n_outputs': n_outputs,
    'mask': mask,
    'cond_label_size': cond_label_size,
}

ARGS = {
    'x': torch.randn(2, input_size),
    'y': torch.randn(2, cond_label_size),
}

if __name__ == '__main__':
    layer = MaskedLinear(**INIT_ARGS)
    output = layer(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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, 3) — shape (2, 3) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
NewCouplingLayer Ran
ran on a synthesized input
e-hulten/real-nvp-2d/new_model.py
pointer only (licence: NONE) · get_code("7abc1ea24d4ec73c")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, e-hulten/real-nvp-2d when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

ScaleTranslate Ran
ran on a synthesized input · constructed an object; no result was computed
e-hulten/real-nvp-2d/new_model.py
pointer only (licence: NONE) · get_code("74841353295bfb2d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, e-hulten/real-nvp-2d when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Shuffle Ran
ran on a synthesized input · constructed an object; no result was computed
mahkons/flows/MAF/MAF.py
code served (permissive licence) · get_code("6dbb94a13701bd3f")
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 an instance of its own class, Shuffle: the run constructed the object and did not call it, so no result was computed. 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

torch.manual_seed(0)

# The Shuffle class expects a permutation tensor `p` as its only parameter
# Looking at the __init__, it:
# 1. Registers `p` as a buffer
# 2. Creates an inverse permutation `inv_p` based on `p`
# 3. Uses `p` in forward_flow to index into dimension 1 of x
# 4. Uses `inv_p` in inverse_flow to index into dimension 1 of x

# Create a valid permutation tensor for dimension 1
# Using a small dimension: 4 elements to permute
p = torch.tensor([2, 0, 3, 1], dtype=torch.long)

ARGS = {
    'p': p
}
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 Shuffle — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a Shuffle 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
get_mask Ran
ran, honoured the contract we drafted
ricokaloklo/denmarf/denmarf/flows.py
code served (permissive licence) · get_code("a4dfb67f7c8176a7")
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 (3, 4) 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

torch.manual_seed(0)

ARGS = {
    'in_features': 4,
    'out_features': 3,
    'in_flow_features': 5,
    'mask_type': 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 (3, 4) — shape (3, 4) 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
get_mask Ran
ran, honoured the contract we drafted
kmzzhang/nbi/src/nbi/nn/flows.py
pointer only (licence: NOASSERTION) · get_code("d580682a49233ab6")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, kmzzhang/nbi (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MAF Not yet run
unverified (harvested, no recorded run)
e-hulten/maf/maf.py
code served (permissive licence) · get_code("866ea62b086bd0dc")
How it ran

no invocation recorded.

MAF Not yet run
unverified (harvested, no recorded run)
mahkons/flows/MAF/MAF.py
code served (permissive licence) · get_code("d96055fcc27e26e3")
How it ran

no invocation recorded.

MAF Not yet run
unverified (harvested, no recorded run)
lifeitech/fce-2d/flows/maf.py
code served (permissive licence) · get_code("11c761294eefa8ee")
How it ran

no invocation recorded.

MaskedSum Not yet run
unverified (harvested, no recorded run)
e-hulten/real-nvp-2d/new_model.py
pointer only (licence: NONE) · get_code("6cc65593a2aa409d")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, e-hulten/real-nvp-2d when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

NewFlow Not yet run
unverified (harvested, no recorded run)
e-hulten/real-nvp-2d/new_model.py
pointer only (licence: NONE) · get_code("a7db3153f7f53ece")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, e-hulten/real-nvp-2d when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

SequentialConditionalFlow Not yet run
unverified (harvested, no recorded run)
mahkons/flows/MAF/MAF.py
code served (permissive licence) · get_code("8f01a25b9ec07b0b")
How it ran

no invocation recorded.

Also present in other papers' code

Of 28 samples lifted from this paper's linked repositories, 28 carry a function identity and 0 do not. Of the 27 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 2 later) and 24 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.

FunctionAlso present inEarliest-datedOthers named
get_mask
brick of this paper's assembly: helper
3 other papers
3 later
2003.05033 (2020-03)
Generalized Energy Based Models
2109.00546 (2021-09)
Classifying Anomalies THrough Outer Density Estimation (CATHODE)
2203.09470 (2022-03)
CURTAINs for your Sliding Window: Constructing Unobserved Regions by Transforming Adjacent Intervals
BatchNorm
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
1605.08803 (2016-05)
Density estimation using Real NVP
MaskedLinear
brick of this paper's assembly: helper
1 other paper
1 later
2202.07857 (2022-02)
Graph-Augmented Normalizing Flows for Anomaly Detection of Multiple Time Series

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-22.

Repositories linked to this paper

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

Abstract

Autoregressive models are among the best performing neural density estimators. We describe an approach for increasing the flexibility of an autoregressive model, based on modelling the random numbers that the model uses internally when generating data. By constructing a stack of autoregressive models, each modelling the random numbers of the next model in the stack, we obtain a type of normalizing flow suitable for density estimation, which we call Masked Autoregressive Flow. This type of flow is closely related to Inverse Autoregressive Flow and is a generalization of Real NVP. Masked Autoregressive Flow achieves state-of-the-art performance in a range of general-purpose density estimation tasks.

For agents

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

get_harvested_code_for_paper("1705.07057")
get_code_for_paper("1705.07057")
have("1705.07057")

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

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

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

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

Connect an agent — have() is free.