SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2007.09070 · 2020

Hybrid Discriminative-Generative Training via Contrastive Learning

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 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; 1 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 6 failures of our instrument; 2 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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.09070.json · badge: /api/ran/2007.09070.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
lhao499/HDGE canonical (classifier label)
classifier basis: census
9 ran · 2 no recorded run
FunctionStatusWhere it lives
flatten Ran
ran, honoured the contract we drafted
lhao499/HDGE/viskit/viskit/core.py
code served (permissive licence) · get_code("20922c79a0929bbf")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family int; no output shape is stated. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-04T22:50:02Z). 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

torch.manual_seed(0)

# The function flatten takes a list of lists and flattens it into a single list
# It iterates through sublists and extracts items from each

# Create a simple nested list structure
nested_list = [
    [1, 2, 3],
    [4, 5],
    [6, 7, 8, 9]
]

ARGS = {
    "l": nested_list
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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
conv3x3 Ran
ran; our contract draft was wrong, not the code
lhao499/HDGE/wideresnet.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from DaikiTanak/manifold_mixup, is pointer only (licence: NONE) · get_code("00e569acd6b45ef0")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from DaikiTanak/manifold_mixup, and GitHub detected no licence in that repository 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.

dict_to_safe_json Ran
ran; our contract draft was wrong, not the code
lhao499/HDGE/logger.py
code served (permissive licence) · get_code("41279dfcda8b39e4")
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 dict. 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

torch.manual_seed(0)

# Test case 1: Dictionary with safe JSON values
test_dict_safe = {
    "name": "test",
    "count": 42,
    "value": 3.14,
    "flag": True,
    "empty": None,
    "list": [1, 2, 3],
    "nested_list": [[1, 2], [3, 4]],
}

# Test case 2: Dictionary with unsafe values that need conversion
tensor = torch.randn(2, 4)
numpy_array = np.array([1, 2, 3])
custom_obj = object()

test_dict_unsafe = {
    "tensor": tensor,
    "numpy_array": numpy_array,
    "custom_object": custom_obj,
    "safe_value": 123,
}

# Test case 3: Dictionary with nested dictionaries
test_dict_nested = {
    "level1": {
        "level2": {
            "value": 99,
            "tensor": torch.randn(2, 4),
        },
        "safe": "string",
    },
    "top_level": 42,
}

# Test case 4: Complex mixed dictionary
test_dict_complex = {
    "string": "hello",
    "integer": 100,
    "float": 2.718,
    "boolean": False,
    "none": None,
    "list_mixed": [1, "two", 3.0, True, None],
    "nested_dict": {
        "inner_tensor": torch.randn(3, 5),
        "inner_safe": [1, 2, 3],
    },
    "numpy": np.array([4, 5, 6]),
}

ARGS = {
    "d": test_dict_complex,
}
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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
flatten Ran
ran on a synthesized input
lhao499/HDGE/viskit/viskit/frontend.py
code served (permissive licence) · get_code("2be75b7ac1ba23d4")
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 list, ndim 1, dtype family int; 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

torch.manual_seed(0)

# The function flatten takes xs and flattens one level of nesting
# It expects xs to be an iterable of iterables
# Each inner iterable y will be iterated over to extract x

# Create a simple nested list structure
xs = [
    [1, 2, 3],
    [4, 5],
    [6, 7, 8, 9]
]

ARGS = {
    "xs": xs
}
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 list, ndim 1, dtype family int — a list 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
init_random Ran
ran on a synthesized input
lhao499/HDGE/utils.py
code served (permissive licence) · get_code("c92bfa3e9d7c78c1")
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, 3, 32, 32) 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)

n_ch = 3
im_sz = 32

def init_random(bs):
    return torch.FloatTensor(bs, n_ch, im_sz, im_sz).uniform_(-1, 1)

ARGS = {
    "bs": 2
}
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, 3, 32, 32) — shape (2, 3, 32, 32) 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
load_progress Ran
ran; our contract draft was wrong, not the code
lhao499/HDGE/viskit/viskit/core.py
code served (permissive licence) · get_code("965e75a1245dd833")
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 dict. 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 csv
import tempfile
import os

# Create a temporary CSV file with some test data
temp_dir = tempfile.mkdtemp()
csv_path = os.path.join(temp_dir, "progress.csv")

with open(csv_path, 'w', newline='') as f:
    writer = csv.writer(f)
    writer.writerow(['epoch', 'loss', 'accuracy'])
    writer.writerow(['1', '0.5', '0.8'])
    writer.writerow(['2', '0.3', '0.9'])
    writer.writerow(['3', '0.2', '0.95'])

ARGS = {
    'progress_csv_path': csv_path
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
simple_separated_format Ran
ran; our contract draft was wrong, not the code
lhao499/HDGE/logger.py
code served (permissive licence) · get_code("d6cc3c153cec4e1d")
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 TableFormat. 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.

from collections import OrderedDict, namedtuple

DataRow = namedtuple('DataRow', ['begin', 'sep', 'end'])

TableFormat = namedtuple('TableFormat', ['lineabove', 'linebelowheader', 'linebetweenrows', 'linebelow', 'headerrow', 'datarow', 'padding', 'with_header_hide'])

def simple_separated_format(separator):
    """Construct a simple TableFormat with columns separated by a separator.

    >>> tsv = simple_separated_format("\\t") ;         tabulate([["foo", 1], ["spam", 23]], tablefmt=tsv) == 'foo \\t 1\\nspam\\t23'
    True

    """
    return TableFormat(None, None, None, None, headerrow=DataRow('', separator, ''), datarow=DataRow('', separator, ''), padding=0, with_header_hide=None)


ARGS = {
    'separator': '\t'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type TableFormat — a TableFormat 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
sliding_mean Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
lhao499/HDGE/viskit/viskit/frontend.py
code served (permissive licence) · get_code("40f81b1d5f51ea76")
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) and returned ndarray, ndim 1, dtype family float, shape (8,) 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 numpy as np

# Construct a small data array for testing
data_array = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0])

# Define the arguments dictionary
ARGS = {
    "data_array": data_array,
    "window": 5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 1, dtype family float, shape (8,) — shape (8,) 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
unique Ran
ran; our contract draft was wrong, not the code
lhao499/HDGE/viskit/viskit/core.py
code served (permissive licence) · get_code("6c7a4a9349a395e9")
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) and returned list, ndim 1, dtype family int; 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

torch.manual_seed(0)

# The function `unique(l)` takes a list and returns unique elements
# It converts the list to a set and back to a list
# So we need to pass a list with some duplicate elements

ARGS = {
    "l": [1, 2, 3, 2, 1, 4, 3, 5]
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family int — a list 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
eval_classification Not yet run
unverified (harvested, no recorded run)
lhao499/HDGE/utils.py
code served (permissive licence) · get_code("6a5225a4bd1230c2")
How it ran

no invocation recorded.

plot Not yet run
unverified (harvested, no recorded run)
lhao499/HDGE/utils.py
code served (permissive licence) · get_code("cb06bf4914b94b48")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 8 are also present in other papers whose code we hold (8 with at least one paper dated earlier, 1 the same month, 6 later) and 3 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
conv3x3 74 other papers
19 dated earlier, 1 the same month, 54 later · 5 only as an assembly brick
1605.07146 (2016-05)
Wide Residual Networks
1707.01629 (2017-07)
Dual Path Networks
1802.05668 (2018-02)
Model compression via distillation and quantization
and 71 more not named here
simple_separated_format 27 other papers
8 dated earlier, 19 later
1903.08254 (2019-03)
Efficient Off-Policy Meta-Reinforcement Learning via Probabilistic Context Variables
1910.11670 (2019-10)
Contextual Imagined Goals for Self-Supervised Robotic Learning
1910.12827 (2019-10)
Entity Abstraction in Visual Model-Based Reinforcement Learning
and 24 more not named here
flatten 21 other papers
8 dated earlier, 13 later
1609.08675 (2016-09)
YouTube-8M: A Large-Scale Video Classification Benchmark
1802.04821 (2018-02)
Evolved Policy Gradients
1811.05014 (2018-11)
NeXtVLAD: An Efficient Neural Network to Aggregate Frame-level Features for Large-scale Video Classification
and 18 more not named here
dict_to_safe_json 6 other papers
1 dated earlier, 5 later
2006.04779 (2020-06)
Conservative Q-Learning for Offline Reinforcement Learning
2210.07484 (2022-10)
Mutual Information Regularized Offline Reinforcement Learning
2405.17098 (2024-05)
Q-value Regularized Transformer for Offline Reinforcement Learning
and 3 more not named here
unique 5 other papers
2 dated earlier, 3 later
1802.04821 (2018-02)
Evolved Policy Gradients
2006.04779 (2020-06)
Conservative Q-Learning for Offline Reinforcement Learning
2210.06518 (2022-10)
Semi-Supervised Offline Reinforcement Learning with Action-Free Trajectories
and 2 more not named here
load_progress 4 other papers
1 dated earlier, 3 later
2006.04779 (2020-06)
Conservative Q-Learning for Offline Reinforcement Learning
2210.06518 (2022-10)
Semi-Supervised Offline Reinforcement Learning with Action-Free Trajectories
2301.12842 (2023-01)
Direct Preference-based Policy Optimization without Reward Modeling
and 1 more not named here
sliding_mean 2 other papers
2 dated earlier
1802.04821 (2018-02)
Evolved Policy Gradients
2006.04779 (2020-06)
Conservative Q-Learning for Offline Reinforcement Learning
flatten 1 other paper
1 dated earlier
2006.04779 (2020-06)
Conservative Q-Learning for Offline Reinforcement Learning

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

Contrastive learning and supervised learning have both seen significant progress and success. However, thus far they have largely been treated as two separate objectives, brought together only by having a shared neural network. In this paper we show that through the perspective of hybrid discriminative-generative training of energy-based models we can make a direct connection between contrastive learning and supervised learning. Beyond presenting this unified view, we show our specific choice of approximation of the energy-based loss outperforms the existing practice in terms of classification accuracy of WideResNet on CIFAR-10 and CIFAR-100. It also leads to improved performance on robustness, out-of-distribution detection, and calibration.

For agents

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

get_harvested_code_for_paper("2007.09070")
get_code_for_paper("2007.09070")
have("2007.09070")

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

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

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

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

Connect an agent — have() is free.