SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1902.04601 · 2019

Contrastive Variational Autoencoder Enhances Salient Features

arXiv · PDF · Open in the Atlas

Code that ran

6 of 10 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 3 have no contract verdict; 2 failures of our instrument; 4 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/1902.04601.json · badge: /api/ran/1902.04601.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
abidlabs/contrastive_vae canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
FunctionStatusWhere it lives
filter_images_by_attribute Ran
ran on a synthesized input
abidlabs/contrastive_vae/celeb_utils.py
code served (permissive licence) · get_code("1619fbf9e0e66efa")
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 float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import os
import pandas as pd
import tempfile
import shutil

# Create a temporary directory structure with minimal test data
temp_dir = tempfile.mkdtemp()
img_dir = os.path.join(temp_dir, 'img_align_celeba')
os.makedirs(img_dir, exist_ok=True)

# Create dummy image files
for i in range(1, 4):
    open(os.path.join(img_dir, f'{i:06d}.jpg'), 'w').close()

# Create a minimal CSV with attributes
df = pd.DataFrame({
    'image_id': ['000001.jpg', '000002.jpg', '000003.jpg'],
    'Smiling': [1, -1, 1],
    'Male': [-1, 1, 1]
})
df.to_csv(os.path.join(temp_dir, 'list_attr_celeba.csv'), index=False)

ARGS = {
    'data_dir': temp_dir,
    'attr': 'Smiling',
    'present': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — 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 float — 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
generate_data Ran
ran on a synthesized input
abidlabs/contrastive_vae/vae_utils.py
code served (permissive licence) · get_code("5cd43143265506a1")
How it ran

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

import numpy as np

ARGS = {
    'n': 100,
    'type': 'linear',
    'leaky_slope': 0.01,
    'contrast': True,
    'tg_var': 0.5,
    'return_params': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_batch Ran
ran, honoured the contract we drafted
abidlabs/contrastive_vae/helper.py
code served (permissive licence) · get_code("beee1bbd18d83411")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 4, dtype family float, shape (2, 128, 128, 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 numpy as np
from PIL import Image
import tempfile
import os

# Create temporary test images
temp_dir = tempfile.mkdtemp()

# Create a simple test image (200x200 RGB)
test_image = Image.new('RGB', (200, 200), color='red')
image_path_1 = os.path.join(temp_dir, 'test_image_1.png')
test_image.save(image_path_1)

# Create another test image
test_image_2 = Image.new('RGB', (200, 200), color='blue')
image_path_2 = os.path.join(temp_dir, 'test_image_2.png')
test_image_2.save(image_path_2)

image_files = [image_path_1, image_path_2]
width = 128
height = 128
mode = 'RGB'

ARGS = {
    'image_files': image_files,
    'width': width,
    'height': height,
    'mode': mode
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 4, dtype family float, shape (2, 128, 128, 3) — shape (2, 128, 128, 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: none by the harness; any seed is in the setup block
get_image Ran
ran on a synthesized input
abidlabs/contrastive_vae/helper.py
code served (permissive licence) · get_code("7e1a84dc738a0cf2")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 3, dtype family int, shape (48, 64, 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 numpy as np
from PIL import Image
import tempfile
import os

# Create a temporary image file
with tempfile.TemporaryDirectory() as tmpdir:
    # Create a simple test image (larger than the crop size to test cropping)
    test_image_path = os.path.join(tmpdir, "test_image.png")
    img = Image.new('RGB', (200, 200), color=(73, 109, 137))
    img.save(test_image_path)
    
    # Define arguments for get_image function
    ARGS = {
        "image_path": test_image_path,
        "width": 64,
        "height": 48,
        "mode": "RGB"
    }
    
    # Keep the temporary directory alive by storing the path
    temp_dir_path = tmpdir
    
    # Recreate the image outside the context manager scope for ARGS
    with tempfile.TemporaryDirectory() as tmpdir2:
        test_image_path2 = os.path.join(tmpdir2, "test_image.png")
        img2 = Image.new('RGB', (200, 200), color=(73, 109, 137))
        img2.save(test_image_path2)
        
        ARGS = {
            "image_path": test_image_path2,
            "width": 64,
            "height": 48,
            "mode": "RGB"
        }

# Create a persistent temporary image for the function to use
import tempfile
import os
from PIL import Image

tmpfile = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
tmpfile.close()
test_img = Image.new('RGB', (200, 200), color=(73, 109, 137))
test_img.save(tmpfile.name)

ARGS = {
    "image_path": tmpfile.name,
    "width": 64,
    "height": 48,
    "mode": "RGB"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family int, shape (48, 64, 3) — shape (48, 64, 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: none by the harness; any seed is in the setup block
images_square_grid Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
abidlabs/contrastive_vae/helper.py
code served (permissive licence) · get_code("58dda232cb5e9f9b")
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 Image. 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 math
import numpy as np
from PIL import Image

# Create a small batch of images with shape (N, H, W, C)
# N=4 images, H=3 height, W=4 width, C=3 channels (RGB)
batch_size = 4
height = 3
width = 4
channels = 3

# Create random image data in range [0, 1]
np.random.seed(0)
images = np.random.rand(batch_size, height, width, channels)

# Scale to reasonable range for visualization
images = images * 200 + 30

ARGS = {
    "images": images,
    "mode": "RGB"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Image — a Image output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Image output the recorded ndim 3 and dtype family int 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
sampling Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
abidlabs/contrastive_vae/celeb_utils.py
code served (permissive licence) · get_code("6a6cd6af807e9036")
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 EagerTensor, ndim 2, dtype family float, shape (2, 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 tensorflow as tf
from tensorflow.keras import backend as K
import numpy as np

# Set seeds for reproducibility
np.random.seed(0)
tf.random.set_seed(0)

# Create small tensors for z_mean and z_log_var
# batch_size = 2, latent_dim = 4
z_mean = tf.constant(np.random.randn(2, 4).astype(np.float32))
z_log_var = tf.constant(np.random.randn(2, 4).astype(np.float32))

# The function expects args to be a tuple/list of [z_mean, z_log_var]
args = (z_mean, z_log_var)

ARGS = {
    "args": args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family float, shape (2, 4) — shape (2, 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
contrastive_vae Not yet run
unverified (harvested, no recorded run)
abidlabs/contrastive_vae/vae_utils.py
code served (permissive licence) · get_code("6d1dfe0b6d6924ec")
How it ran

no invocation recorded.

get_celeb_vae Not yet run
unverified (harvested, no recorded run)
abidlabs/contrastive_vae/celeb_utils.py
code served (permissive licence) · get_code("2ed90c0d274151e4")
How it ran

no invocation recorded.

resize_and_crop Not yet run
unverified (harvested, no recorded run)
abidlabs/contrastive_vae/utils.py
code served (permissive licence) · get_code("d54b11d7a042cff2")
How it ran

no invocation recorded.

standard_vae Not yet run
unverified (harvested, no recorded run)
abidlabs/contrastive_vae/vae_utils.py
code served (permissive licence) · get_code("dbfcb3d16e815fb6")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 5 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 4 later) and 5 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_batch 2 other papers
1 dated earlier, 1 later
1812.04948 (2018-12)
A Style-Based Generator Architecture for Generative Adversarial Networks
2402.11928 (2024-02)
Separating common from salient patterns with Contrastive Representation Learning
sampling 2 other papers
1 dated earlier, 1 later
1312.6114 (2013-12)
Auto-Encoding Variational Bayes
2106.07035 (2021-06)
Deep Bayesian Unsupervised Lifelong Learning
get_image 1 other paper
1 dated earlier
1812.04948 (2018-12)
A Style-Based Generator Architecture for Generative Adversarial Networks
images_square_grid 1 other paper
1 later
2402.11928 (2024-02)
Separating common from salient patterns with Contrastive Representation Learning
resize_and_crop 1 other paper
1 later
2210.15752 (2022-10)
Constrained Predictive Coding as a Biologically Plausible Model of the Cortical Hierarchy

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

Variational autoencoders are powerful algorithms for identifying dominant latent structure in a single dataset. In many applications, however, we are interested in modeling latent structure and variation that are enriched in a target dataset compared to some background---e.g. enriched in patients compared to the general population. Contrastive learning is a principled framework to capture such enriched variation between the target and background, but state-of-the-art contrastive methods are limited to linear models. In this paper, we introduce the contrastive variational autoencoder (cVAE), which combines the benefits of contrastive learning with the power of deep generative models. The cVAE is designed to identify and enhance salient latent features. The cVAE is trained on two related but unpaired datasets, one of which has minimal contribution from the salient latent features. The cVAE explicitly models latent features that are shared between the datasets, as well as those that are enriched in one dataset relative to the other, which allows the algorithm to isolate and enhance the salient latent features. The algorithm is straightforward to implement, has a similar run-time to the standard VAE, and is robust to noise and dataset purity. We conduct experiments across diverse types of data, including gene expression and facial images, showing that the cVAE effectively uncovers latent structure that is salient in a particular analysis.

For agents

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

get_harvested_code_for_paper("1902.04601")
get_code_for_paper("1902.04601")
have("1902.04601")

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

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

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

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

Connect an agent — have() is free.