SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1906.02691 · 2019

An Introduction to Variational Autoencoders

arXiv · PDF · Open in the Atlas

Code that ran

4 of 6 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 4 have no contract verdict; 0 failures of our instrument; 2 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/1906.02691.json · badge: /api/ran/1906.02691.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
pycroscopy/atomai community (classifier label)
classifier basis not recorded on the link
4 ran · 2 no recorded run
FunctionStatusWhere it lives
kld_discrete Ran
ran on a synthesized input
pycroscopy/atomai/atomai/losses_metrics/vi_losses.py
code served (permissive licence) · get_code("3189fc551c2bdf3a")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 1, dtype family float, shape (1,) 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 numpy as np

torch.manual_seed(0)

# Create a small alpha tensor
# The function expects alpha to have shape (batch_size, num_categories)
# It calls alpha.size(-1) to get cat_dim
# It then sums over dim=1 and takes mean over dim=0
# So we need at least 2 dimensions
alpha = torch.tensor([
    [0.25, 0.30, 0.25, 0.20],
    [0.10, 0.40, 0.30, 0.20]
], dtype=torch.float32)

ARGS = {
    "alpha": alpha
}
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 1, dtype family float, shape (1,) — shape (1,) 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
kld_normal Ran
ran on a synthesized input
pycroscopy/atomai/atomai/losses_metrics/vi_losses.py
code served (permissive licence) · get_code("fe54e3e64c122d44")
How it ran

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

import torch

torch.manual_seed(0)

# q_param: tuple of (mu_1, log_sd_1) - two tensors
mu_1 = torch.randn(2, 4)
log_sd_1 = torch.randn(2, 4)
q_param = (mu_1, log_sd_1)

# p_param: optional tuple of (mu_2, log_sd_2) - two tensors
# We'll provide a non-None value
mu_2 = torch.randn(2, 4)
log_sd_2 = torch.randn(2, 4)
p_param = (mu_2, log_sd_2)

ARGS = {
    "q_param": q_param,
    "p_param": p_param,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
reconstruction_loss Ran
ran on a synthesized input
pycroscopy/atomai/atomai/losses_metrics/vi_losses.py
code served (permissive licence) · get_code("0460cf38488e57d7")
How it ran

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

import torch
import numpy as np

torch.manual_seed(0)

# Test case 1: MSE loss with 2D input
batch_size = 2
in_dim_2d = (4, 3)
x_2d = torch.randn(batch_size, 4, 3)
x_reconstr_2d = torch.randn(batch_size, 4, 3)

# Test case 2: Cross-entropy loss with 3D input (e.g., images with channels)
in_dim_3d = (4, 3, 2)
x_3d = torch.sigmoid(torch.randn(batch_size, 4, 3, 2))
x_reconstr_3d = torch.randn(batch_size, 4, 3, 2)

ARGS = {
    "loss_type": "mse",
    "in_dim": in_dim_2d,
    "x": x_2d,
    "x_reconstr": x_reconstr_2d,
    "logits": 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 Tensor, ndim 1, dtype family float, shape (2,) — shape (2,) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_loss Ran
ran on a synthesized input
pycroscopy/atomai/atomai/losses_metrics/losses.py
code served (permissive licence) · get_code("f7577f8b26a9ee05")
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 focal_loss. 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 torch.nn.functional as F

torch.manual_seed(0)

# Define minimal loss function classes for testing
class focal_loss(nn.Module):
    def __init__(self, alpha: int=0.5, gamma: int=2, with_logits: bool=True) -> None:
        super(focal_loss, self).__init__()
        self.alpha = alpha
        self.gamma = gamma
        self.logits = with_logits

    def forward(self, prediction: torch.Tensor, labels: torch.Tensor):
        if self.logits:
            CE_loss = F.binary_cross_entropy_with_logits(prediction, labels)
        else:
            CE_loss = F.binary_cross_entropy(prediction, labels)
        pt = torch.exp(-CE_loss)
        F_loss = self.alpha * (1 - pt) ** self.gamma * CE_loss
        return F_loss

class dice_loss(nn.Module):
    def __init__(self, eps: float=1e-07):
        super(dice_loss, self).__init__()
        self.eps = eps

    def forward(self, logits: torch.Tensor, labels: torch.Tensor) -> torch.Tensor:
        num_classes = logits.shape[1]
        if num_classes == 1:
            true_1_hot = torch.eye(num_classes + 1)[labels.squeeze(1).long()]
            true_1_hot = true_1_hot.permute(0, 3, 1, 2).contiguous().float()
            true_1_hot_f = true_1_hot[:, 0:1, :, :]
            true_1_hot_s = true_1_hot[:, 1:2, :, :]
            true_1_hot = torch.cat([true_1_hot_s, true_1_hot_f], dim=1)
            pos_prob = torch.sigmoid(logits)
            neg_prob = 1 - pos_prob
            probas = torch.cat([pos_prob, neg_prob], dim=1)
        else:
            true_1_hot = torch.eye(num_classes)[labels.long()]
            true_1_hot = true_1_hot.permute(0, 3, 1, 2).contiguous().float()
            probas = F.softmax(logits, dim=1)
        true_1_hot = true_1_hot.type(logits.type())
        dims = (0,) + tuple(range(2, labels.ndimension()))
        intersection = torch.sum(probas * true_1_hot, dims)
        cardinality = torch.sum(probas + true_1_hot, dims)
        dice_loss = (2.0 * intersection / (cardinality + self.eps)).mean()
        return 1 - dice_loss

class MultiTaskLoss(nn.Module):
    def __init__(self, num_tasks: int, loss_fn=nn.NLLLoss, weights=None):
        super(MultiTaskLoss, self).__init__()
        self.loss_functions = [loss_fn() for _ in range(num_tasks)]
        if weights is not None:
            assert len(weights) == num_tasks, 'The length of weights must match num_tasks'
            self.weights = weights
        else:
            self.weights = [1.0] * num_tasks

    def forward(self, outputs, labels):
        individual_losses = [weight * loss_fn(output, label) for weight, loss_fn, output, label in zip(self.weights, self.loss_functions, outputs, labels)]
        total_loss = sum(individual_losses)
        return total_loss

def select_loss(loss: str, nb_classes: int=None, **kwargs):
    if loss in ['ce', 'multitask'] and nb_classes is None:
        raise ValueError('For cross-entropy loss function, you must' + ' specify the number of classes')
    if loss == 'multitask' and (not isinstance(nb_classes, list)):
        raise ValueError('Provide number of classes for each task as a list')
    if loss == 'dice':
        criterion = dice_loss()
    elif loss == 'focal':
        criterion = focal_loss(**kwargs)
    elif loss == 'ce':
        criterion = nn.CrossEntropyLoss()
    elif loss == 'multitask':
        criterion = MultiTaskLoss(num_tasks=len(nb_classes), **kwargs)
    return criterion

ARGS = {
    'loss': 'focal',
    'nb_classes': 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 focal_loss — a focal_loss output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a focal_loss 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
init_VAE_nets Not yet run
unverified (harvested, no recorded run)
pycroscopy/atomai/atomai/nets/ed.py
code served (permissive licence) · get_code("ddc3e7e68d04d286")
How it ran

no invocation recorded.

init_imspec_model Not yet run
unverified (harvested, no recorded run)
pycroscopy/atomai/atomai/nets/ed.py
code served (permissive licence) · get_code("c63a7a34ed576637")
How it ran

no invocation recorded.

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-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 provide a principled framework for learning deep latent-variable models and corresponding inference models. In this work, we provide an introduction to variational autoencoders and some important extensions.

For agents

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

get_harvested_code_for_paper("1906.02691")
get_code_for_paper("1906.02691")
have("1906.02691")

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

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

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

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

Connect an agent — have() is free.