SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1901.05534 · 2019

Lagging Inference Networks and Posterior Collapse in Variational Autoencoders

arXiv · PDF · Open in the Atlas

Code that ran

7 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; 0 honoured the contract we drafted, 0 violated it and 6 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/1901.05534.json · badge: /api/ran/1901.05534.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
jxhe/vae-lagging-encoder canonical (classifier label)
classifier basis: census
7 ran · 3 no recorded run
FunctionStatusWhere it lives
calc_au Ran
ran on a synthesized input
jxhe/vae-lagging-encoder/image.py
code served (permissive licence) · get_code("6fcc55204af86253")
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 torch
import torch.nn as nn
from torch.utils.data import DataLoader

torch.manual_seed(0)

class SimpleVAE(nn.Module):
    def __init__(self, latent_dim=4):
        super().__init__()
        self.latent_dim = latent_dim
        self.encoder = nn.Linear(3, latent_dim * 2)
    
    def encode_stats(self, batch_data):
        """Return mean and logvar of latent distribution"""
        stats = self.encoder(batch_data)
        mean = stats[:, :self.latent_dim]
        logvar = stats[:, self.latent_dim:]
        return mean, logvar

# Create a tiny model
model = SimpleVAE(latent_dim=4)

# Create a tiny test loader with 2 batches of size 2, input dim 3
batch_data_1 = torch.randn(2, 3)
batch_data_2 = torch.randn(2, 3)
batch_labels_1 = torch.tensor([0, 1])
batch_labels_2 = torch.tensor([1, 0])

test_loader = [
    (batch_data_1, batch_labels_1),
    (batch_data_2, batch_labels_2),
]

ARGS = {
    "model": model,
    "test_loader": test_loader,
    "delta": 0.01,
}
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 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
calc_iwnll Ran
ran on a synthesized input
jxhe/vae-lagging-encoder/text.py
code served (permissive licence) · get_code("831c1b0d4145f843")
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, 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 torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create a minimal model that implements the nll_iw method
class MinimalVAE(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def nll_iw(self, batch_data, nsamples, ns):
        # batch_data is a tensor of shape (batch_size, sent_len)
        # Return a tensor that can be summed
        batch_size, sent_len = batch_data.size()
        # Return a loss tensor with one value per sample in batch
        return torch.randn(batch_size)

# Create test data batch - list of tensors
# Each tensor is (batch_size, sent_len)
test_data_batch = [
    torch.randint(0, 10, (2, 4)),  # batch_size=2, sent_len=4
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
    torch.randint(0, 10, (2, 4)),
]

# Create args object with iw_nsamples attribute
class Args:
    def __init__(self):
        self.iw_nsamples = 5

ARGS = {
    'model': MinimalVAE(),
    'test_data_batch': test_data_batch,
    'args': Args(),
    'ns': 100
}
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 tuple, ndim 1, dtype family float — a tuple 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
calc_mi Ran
ran on a synthesized input
jxhe/vae-lagging-encoder/image.py
code served (permissive licence) · get_code("9cf81d81989d6812")
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)

# Create a minimal model that has the calc_mi_q method
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def calc_mi_q(self, batch_data):
        # Return a scalar mutual information value
        # The function multiplies this by batch_size, so return a reasonable scalar
        return torch.tensor(0.5)

# Create test_loader as a list of (batch_data, labels) tuples
# Each batch has 2 samples with 4 features
batch_data_1 = torch.randn(2, 4)
labels_1 = torch.tensor([0, 1])

batch_data_2 = torch.randn(2, 4)
labels_2 = torch.tensor([1, 0])

test_loader = [
    (batch_data_1, labels_1),
    (batch_data_2, labels_2)
]

model = MinimalModel()

ARGS = {
    "model": model,
    "test_loader": test_loader
}
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
calc_mi Ran
ran on a synthesized input
jxhe/vae-lagging-encoder/text.py
code served (permissive licence) · get_code("2d2593fbf606c876")
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 MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 2)
    
    def calc_mi_q(self, batch_data):
        # Returns a scalar mutual information value
        # batch_data is expected to be a tensor of shape (batch_size, 4)
        return torch.tensor(0.5)

# Create model instance
model = MockModel()

# Create test data batch - a list of batches
# Each batch is a tensor of shape (batch_size, feature_dim)
test_data_batch = [
    torch.randn(2, 4),  # First batch: 2 examples, 4 features
    torch.randn(3, 4),  # Second batch: 3 examples, 4 features
]

ARGS = {
    "model": model,
    "test_data_batch": test_data_batch,
}
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
generate_grid Ran
ran on a synthesized input
jxhe/vae-lagging-encoder/modules/utils.py
code served (permissive licence) · get_code("69f9f574272f9c32")
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 torch

torch.manual_seed(0)

ARGS = {
    "zmin": 0.0,
    "zmax": 2.0,
    "dz": 0.5,
    "device": "cpu",
    "ndim": 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 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
log_sum_exp Ran
ran; our contract draft was wrong, not the code
jxhe/vae-lagging-encoder/modules/utils.py
code served (permissive licence) · get_code("5efe6eb2209f6591")
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)

# Create a small tensor for testing log_sum_exp
# The function operates on a single tensor and optionally reduces along a dimension
value = torch.randn(2, 4)

# Test case 1: with dim specified
ARGS = {
    "value": value,
    "dim": 1,
    "keepdim": 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 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
test Ran
ran on a synthesized input
jxhe/vae-lagging-encoder/text.py
code served (permissive licence) · get_code("3884f3eb2fb3adc2")
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, 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 torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

class MockVAE(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def calc_mi_q(self, batch_data):
        # Returns a scalar mutual information value
        return torch.tensor(0.5)
    
    def loss(self, batch_data, beta, nsamples):
        # Returns (loss, loss_rc, loss_kl) where loss_rc and loss_kl don't require grad
        batch_size = batch_data.size(0)
        loss_rc = torch.tensor([0.1] * batch_size, requires_grad=False)
        loss_kl = torch.tensor([0.05] * batch_size, requires_grad=False)
        loss = loss_rc.sum() + loss_kl.sum()
        return loss, loss_rc, loss_kl

class MockArgs:
    def __init__(self):
        self.nsamples = 1

# Create test data batch - list of tensors
# Each tensor has shape (batch_size, sent_len)
batch1 = torch.randint(0, 100, (2, 5))  # 2 examples, length 5
batch2 = torch.randint(0, 100, (2, 5))  # 2 examples, length 5
test_data_batch = [batch1, batch2]

model = MockVAE()
mode = "test"
args = MockArgs()

ARGS = {
    "model": model,
    "test_data_batch": test_data_batch,
    "mode": mode,
    "args": args,
    "verbose": 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 tuple, ndim 1, dtype family float — a tuple 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
get_confirm_token Not yet run
unverified (harvested, no recorded run)
jxhe/vae-lagging-encoder/prepare_data.py
pointer only (licence: MIT); the stored copy get_code serves, from med-air/FedBN, is pointer only (licence: NONE) · get_code("135b3dc835ffe6ad")
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 med-air/FedBN, 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. No invocation recorded.

test Not yet run
unverified (harvested, no recorded run)
jxhe/vae-lagging-encoder/image.py
code served (permissive licence) · get_code("79e431252f32cf60")
How it ran

no invocation recorded.

test Not yet run
unverified (harvested, no recorded run)
jxhe/vae-lagging-encoder/toy.py
code served (permissive licence) · get_code("3d3feb42f9c79a9e")
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, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 later) and 7 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_confirm_token 38 other papers
15 dated earlier, 23 later
1409.8230 (2014-09)
RENOIR - A Dataset for Real Low-Light Image Noise Reduction
1503.03832 (2015-03)
FaceNet: A Unified Embedding for Face Recognition and Clustering
1506.03134 (2015-06)
Pointer Networks
and 35 more not named here
log_sum_exp 5 other papers
5 later
2004.12585 (2020-04)
A Batch Normalized Inference Network Keeps the KL Vanishing Away
2110.12381 (2021-10)
Regularizing Variational Autoencoder with Diversity and Uncertainty Awareness
2207.06130 (2022-07)
Fuse It More Deeply! A Variational Transformer with Layer-Wise Latent Variable Inference for Text Generation
and 2 more not named here
generate_grid 1 other paper
1 later
2004.12585 (2020-04)
A Batch Normalized Inference Network Keeps the KL Vanishing Away

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

The variational autoencoder (VAE) is a popular combination of deep latent variable model and accompanying variational learning technique. By using a neural inference network to approximate the model's posterior on latent variables, VAEs efficiently parameterize a lower bound on marginal data likelihood that can be optimized directly via gradient methods. In practice, however, VAE training often results in a degenerate local optimum known as "posterior collapse" where the model learns to ignore the latent variable and the approximate posterior mimics the prior. In this paper, we investigate posterior collapse from the perspective of training dynamics. We find that during the initial stages of training the inference network fails to approximate the model's true posterior, which is a moving target. As a result, the model is encouraged to ignore the latent encoding and posterior collapse occurs. Based on this observation, we propose an extremely simple modification to VAE training to reduce inference lag: depending on the model's current mutual information between latent variable and observation, we aggressively optimize the inference network before performing each model update. Despite introducing neither new model components nor significant complexity over basic VAE, our approach is able to avoid the problem of collapse that has plagued a large amount of previous work. Empirically, our approach outperforms strong autoregressive baselines on text and image benchmarks in terms of held-out likelihood, and is competitive with more complex techniques for avoiding collapse while being substantially faster.

For agents

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

get_harvested_code_for_paper("1901.05534")
get_code_for_paper("1901.05534")
have("1901.05534")

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

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

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

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

Connect an agent — have() is free.