SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2007.03317 · NeurIPS · 2020

Efficient Learning of Generative Models via Finite-Difference Score Matching

Yang Song, Stefano Ermon, Tianyu Pang, Jun Zhu, Kun Xu, Chongxuan Li

arXiv · PDF · Open in the Atlas

Code that ran

11 of 14 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 10 have no contract verdict; 1 failure of our instrument; 3 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/2007.03317.json · badge: /api/ran/2007.03317.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
taufikxu/FD-ScoreMatching canonical (classifier label)
classifier basis: census
11 ran · 3 no recorded run
FunctionStatusWhere it lives
dsm Ran
ran; our contract draft was wrong, not the code
taufikxu/FD-ScoreMatching/SSM/losses/dsm.py
pointer only (licence: MIT); the stored copy get_code serves, from ermongroup/ncsn, is pointer only (licence: GPL-3.0) · get_code("1492fccd0aa41223")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from ermongroup/ncsn, and GPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

dsm_fd Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/SSM/losses/efficient_sm.py
code served (permissive licence) · get_code("595dc4b579f696d3")
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 0, dtype family float, shape () 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 SimpleEnergyNet(nn.Module):
    def __init__(self, dim):
        super().__init__()
        self.linear = nn.Linear(dim, 1)
    
    def forward(self, x):
        return self.linear(x).squeeze(-1)

energy_net = SimpleEnergyNet(dim=4)
samples = torch.randn(2, 4)

ARGS = {
    "energy_net": energy_net,
    "samples": samples,
    "sigma": 1,
    "eps": 0.001,
}
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 0, dtype family float, shape () — shape () 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
dsm_multi_scale Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/DeepEBM/ESM/loss_demo.py
code served (permissive licence) · get_code("874e2e5f1e75a832")
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 0, dtype family float, shape () 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 SimpleEnergyModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 1)
    
    def forward(self, x):
        # x shape: (batch, channels, height, width)
        # Flatten and compute energy
        batch_size = x.shape[0]
        x_flat = x.view(batch_size, -1)
        energy = self.linear(x_flat)
        return energy

energy_model = SimpleEnergyModel()

x_real = torch.randn(2, 1, 2, 2)

sigmas = torch.tensor([1.0, 0.5])

sigma02 = torch.tensor([0.1, 0.1])

ARGS = {
    "energy": energy_model,
    "x_real": x_real,
    "sigmas": sigmas,
    "sigma02": sigma02
}
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 0, dtype family float, shape () — shape () 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
dsm_tracetrick Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/SSM/losses/dsm.py
code served (permissive licence) · get_code("bd6e572302d366ca")
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 0, dtype family float, shape () 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)

# Define a simple energy network that takes samples and outputs a scalar energy
class EnergyNet(nn.Module):
    def __init__(self, input_dim):
        super().__init__()
        self.fc1 = nn.Linear(input_dim, 8)
        self.fc2 = nn.Linear(8, 1)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

# Create energy network
energy_net = EnergyNet(input_dim=4)

# Create sample tensor (batch_size=2, dim=4)
samples = torch.randn(2, 4, requires_grad=False)

# Define sigma
sigma = 1.0

ARGS = {
    "energy_net": energy_net,
    "samples": samples,
    "sigma": sigma
}
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 Tensor, ndim 0, dtype family float, shape () — shape () 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
efficient_score_matching_conjugate Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/SSM/losses/efficient_sm.py
code served (permissive licence) · get_code("1bde925eee0e6851")
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 0, dtype family float, shape () 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)

# Define a simple energy network that takes concatenated input and outputs energy values
class EnergyNet(nn.Module):
    def __init__(self, input_dim):
        super().__init__()
        self.linear1 = nn.Linear(input_dim, 8)
        self.linear2 = nn.Linear(8, 1)
    
    def forward(self, x):
        x = torch.relu(self.linear1(x))
        x = self.linear2(x)
        return x.squeeze(-1)

# Create instances
batch_size = 2
dim = 4

energy_net = EnergyNet(input_dim=dim)

# Create sample data
samples = torch.randn(batch_size, dim)

# Create noise (optional, can be None)
noise = torch.randn(batch_size, dim)

ARGS = {
    'energy_net': energy_net,
    'samples': samples,
    'noise': noise,
    'eps': 0.1,
    'noise_type': 'sphere',
    'detach': 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 Tensor, ndim 0, dtype family float, shape () — shape () 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
exact_score_matching_old Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/SSM/losses/score_matching.py
code served (permissive licence) · get_code("2fdedceeec3a9bd6")
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 0, dtype family float, shape () 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 torch.autograd as autograd

torch.manual_seed(0)

# Create a simple energy network that takes samples and outputs a scalar energy per sample
class EnergyNet(nn.Module):
    def __init__(self, input_dim):
        super().__init__()
        self.linear1 = nn.Linear(input_dim, 8)
        self.linear2 = nn.Linear(8, 1)
    
    def forward(self, x):
        # x shape: (batch_size, input_dim)
        # output shape: (batch_size,)
        h = torch.relu(self.linear1(x))
        return self.linear2(h).squeeze(-1)

# Create energy network
energy_net = EnergyNet(input_dim=4)

# Create sample tensor: batch_size=2, feature_dim=4
samples = torch.randn(2, 4, requires_grad=True, dtype=torch.float32)

# Define arguments
ARGS = {
    'energy_net': energy_net,
    'samples': samples,
    'train': 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 Tensor, ndim 0, dtype family float, shape () — shape () 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
reshape_factor Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/DeepEBM/ESM/model_condition.py
code served (permissive licence) · get_code("6b5f231263f6eb40")
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 4, dtype family float, shape (2, 16, 4, 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
import torch.nn as nn

torch.manual_seed(0)

# Construct arguments for reshape_factor
# The function takes a tensor x_in and reshapes/permutes it based on factor, in_c, and hw

# x_in: input tensor with shape (batch, in_c, hw, hw)
batch_size = 2
in_c = 4
hw = 8
factor = 2

x_in = torch.randn(batch_size, in_c, hw, hw)

ARGS = {
    "x_in": x_in,
    "factor": factor,
    "in_c": in_c,
    "hw": hw
}
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 4, dtype family float, shape (2, 16, 4, 4) — shape (2, 16, 4, 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
single_efficient_score_matching Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/SSM/losses/efficient_sm.py
code served (permissive licence) · get_code("0f4e80bfcddbb1dc")
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 0, dtype family float, shape () 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 SimpleEnergyNet(nn.Module):
    def __init__(self, input_dim):
        super().__init__()
        self.fc1 = nn.Linear(input_dim, 8)
        self.fc2 = nn.Linear(8, 1)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

energy_net = SimpleEnergyNet(input_dim=4)

samples = torch.randn(2, 4)

ARGS = {
    'energy_net': energy_net,
    'samples': samples,
    'eps': 0.01,
    'noise_type': 'sphere'
}
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 0, dtype family float, shape () — shape () 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
soft_binary_cross_entropy Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/DeepEBM/Torture/loss_function.py
code served (permissive licence) · get_code("3b5b96bba781a82e")
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 0, dtype family float, shape () 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.functional as F

torch.manual_seed(0)

# Construct logits tensor: batch_size=2, num_classes=4
logits = torch.randn(2, 4)

# Construct label tensor: same shape as logits, with soft labels (probabilities)
label = torch.rand(2, 4)

# Define reduce_mean parameter
reduce_mean = True

ARGS = {
    "logits": logits,
    "label": label,
    "reduce_mean": reduce_mean,
}
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 0, dtype family float, shape () — shape () 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
soft_cross_entropy Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/DeepEBM/Torture/loss_function.py
code served (permissive licence) · get_code("fbd5704657ae5a16")
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 0, dtype family float, shape () 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)

# Create logits: batch_size=2, num_classes=4
logits = torch.randn(2, 4)

# Create soft labels (probabilities that sum to 1 across last dimension)
# batch_size=2, num_classes=4
label = torch.softmax(torch.randn(2, 4), dim=-1)

# reduce_mean can be True or False
reduce_mean = True

ARGS = {
    "logits": logits,
    "label": label,
    "reduce_mean": reduce_mean,
}
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 0, dtype family float, shape () — shape () 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
soft_cross_entropy_sparse Ran
ran on a synthesized input
taufikxu/FD-ScoreMatching/DeepEBM/Torture/loss_function.py
code served (permissive licence) · get_code("a6715e5746275de0")
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 0, dtype family float, shape () 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.functional as F

torch.manual_seed(0)

# Construct tiny tensors for the function
batch_size = 2
num_classes = 4

# logits: shape (batch_size, num_classes)
logits = torch.randn(batch_size, num_classes)

# label: shape (batch_size,) with class indices in range [0, num_classes)
label = torch.tensor([0, 2], dtype=torch.long)

# reduce_mean parameter
reduce_mean = True

ARGS = {
    "logits": logits,
    "label": label,
    "num_classes": num_classes,
    "reduce_mean": reduce_mean,
}
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 0, dtype family float, shape () — shape () 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
exact_score_matching Not yet run
unverified (harvested, no recorded run)
taufikxu/FD-ScoreMatching/DeepEBM/ESM/loss_train.py
code served (permissive licence) · get_code("a63496399c14609a")
How it ran

no invocation recorded.

score_matching Not yet run
unverified (harvested, no recorded run)
taufikxu/FD-ScoreMatching/DeepEBM/ESM/loss_demo.py
code served (permissive licence) · get_code("7e568b8e4b4cc379")
How it ran

no invocation recorded.

score_matching Not yet run
unverified (harvested, no recorded run)
taufikxu/FD-ScoreMatching/SSM/losses/score_matching.py
code served (permissive licence) · get_code("6a824135346a2418")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 13 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
dsm 2 other papers
2 later
2111.04726 (2021-11)
Estimating High Order Gradients of the Data Distribution by Denoising
2506.07841 (2025-06)
Diffusion models under low-noise regime

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

Several machine learning applications involve the optimization of higher-order derivatives (e.g., gradients of gradients) during training, which can be expensive with respect to memory and computation even with automatic differentiation. As a typical example in generative modeling, score matching (SM) involves the optimization of the trace of a Hessian. To improve computing efficiency, we rewrite the SM objective and its variants in terms of directional derivatives, and present a generic strategy to efficiently approximate any-order directional derivative with finite difference (FD). Our approximation only involves function evaluations, which can be executed in parallel, and no gradient computations. Thus, it reduces the total computational cost while also improving numerical stability. We provide two instantiations by reformulating variants of SM objectives into the FD forms. Empirically, we demonstrate that our methods produce results comparable to the gradient-based counterparts while being much more computationally efficient.

For agents

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

get_harvested_code_for_paper("2007.03317")
get_code_for_paper("2007.03317")
have("2007.03317")

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

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

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

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

Connect an agent — have() is free.