SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2302.06576 · ICML · 2023

GFlowNet-EM for Learning Compositional Latent Variable Models

Yoshua Bengio, Moksh Jain, Edward Hu, Nikolay Malkin, Alexandros Graikos, Katie Everett

arXiv · PDF · Open in the Atlas

Code that ran

3 of 4 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 0 have no contract verdict; 3 failures of our instrument; 1 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/2302.06576.json · badge: /api/ran/2302.06576.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
GFNOrg/GFlowNet-EM canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
gfnorg/gflownet-em marked official in Papers with Code
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
binarize_static Ran
ran; our contract draft was wrong, not the code
GFNOrg/GFlowNet-EM/discrete_vae/gfn/train_gfn.py
code served (permissive licence) · get_code("4e16af7e5dbea818")
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 Tensor, 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 torch

torch.manual_seed(0)

# The function binarize_static takes a single parameter x
# and applies a threshold operation (x > 0.5) then converts to float
# x should be a tensor

x = torch.rand(2, 4)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 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
sample Ran
ran; our contract draft was wrong, not the code
GFNOrg/GFlowNet-EM/discrete_vae/gfn/train_gfn.py
code served (permissive licence) · get_code("bf574d554afe6839")
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 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
import torch.nn.functional as F

torch.manual_seed(0)

class MockGFlowNet(nn.Module):
    def __init__(self, dictionary_size=4, lh=3, lw=3, img_channels=3):
        super().__init__()
        self.dictionary_size = dictionary_size
        self.lh = lh
        self.lw = lw
        self.img_channels = img_channels
        
        # Simple network that takes image and state and outputs logits
        # Input: img (batch, channels, h, w) + state (batch, dict_size*lh*lw)
        # Output: logits (batch, dict_size*lh*lw)
        self.conv = nn.Conv2d(img_channels, 8, kernel_size=3, padding=1)
        self.fc1 = nn.Linear(8 * lh * lw + dictionary_size * lh * lw, 64)
        self.fc2 = nn.Linear(64, dictionary_size * lh * lw)
    
    def forward(self, img, state):
        # img shape: (batch, channels, h, w)
        # state shape: (batch, dict_size*lh*lw)
        batch_size = img.shape[0]
        
        # Process image
        x = self.conv(img)  # (batch, 8, lh, lw)
        x = x.view(batch_size, -1)  # (batch, 8*lh*lw)
        
        # Concatenate with state
        x = torch.cat([x, state], dim=1)  # (batch, 8*lh*lw + dict_size*lh*lw)
        
        # Pass through FC layers
        x = F.relu(self.fc1(x))
        logits = self.fc2(x)  # (batch, dict_size*lh*lw)
        
        return logits

# Create mock GFlowNet
gfn = MockGFlowNet(dictionary_size=4, lh=3, lw=3, img_channels=3)

# Create image tensor (batch_size=2, channels=3, height=3, width=3)
img = torch.randn(2, 3, 3, 3)

# Define arguments
ARGS = {
    'gfn': gfn,
    'img': img,
    'p': 1.0,
    'rand_prob': 0.05
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
sleep_step Ran
ran; our contract draft was wrong, not the code
GFNOrg/GFlowNet-EM/discrete_vae/gfn/train_gfn.py
code served (permissive licence) · get_code("0461df5888f82edd")
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 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
import torch.nn.functional as F

torch.manual_seed(0)

# Build GFN network
class GFNNet(nn.Module):
    def __init__(self, dictionary_size=8, embedding_dim=16, lh=4, lw=4):
        super().__init__()
        self.dictionary_size = dictionary_size
        self.embedding_dim = embedding_dim
        self.lh = lh
        self.lw = lw
        # Input: image (batch, 1, lh, lw) + state (batch, dict_size*lh*lw)
        # Output: logits for each position (batch, dict_size*lh*lw)
        self.fc = nn.Linear(1 * lh * lw + dictionary_size * lh * lw, dictionary_size * lh * lw)
    
    def forward(self, img, state):
        # img shape: (batch, 1, lh, lw)
        # state shape: (batch, dict_size*lh*lw)
        batch_size = img.shape[0]
        img_flat = img.view(batch_size, -1)
        combined = torch.cat([img_flat, state], dim=1)
        logits = self.fc(combined)
        return logits

# Build Decoder network
class Decoder(nn.Module):
    def __init__(self, embedding_dim=16, lh=4, lw=4):
        super().__init__()
        self.embedding_dim = embedding_dim
        self.lh = lh
        self.lw = lw
        # Input: state (batch, embedding_dim, lh, lw)
        # Output: image probabilities (batch, 1, lh, lw)
        self.conv = nn.Conv2d(embedding_dim, 1, kernel_size=1)
    
    def forward(self, x):
        # x shape: (batch, embedding_dim, lh, lw)
        out = self.conv(x)
        return torch.sigmoid(out)

# Build latent dictionary
class LatentDict(nn.Module):
    def __init__(self, dictionary_size=8, embedding_dim=16):
        super().__init__()
        self.dictionary = nn.Embedding(dictionary_size, embedding_dim)
    
    def forward(self, x):
        return self.dictionary(x)

# Create instances
device = torch.device('cpu')
dictionary_size = 8
embedding_dim = 16
lh = 4
lw = 4
batch_size = 2

gfn = GFNNet(dictionary_size=dictionary_size, embedding_dim=embedding_dim, lh=lh, lw=lw).to(device)
decoder = Decoder(embedding_dim=embedding_dim, lh=lh, lw=lw).to(device)
latent_dict = LatentDict(dictionary_size=dictionary_size, embedding_dim=embedding_dim).to(device)

ARGS = {
    'gfn': gfn,
    'decoder': decoder,
    'latent_dict': latent_dict,
    'batch_size': batch_size
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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
GFN_controller Not yet run
unverified (harvested, no recorded run)
gfnorg/gflownet-em/grammars/gflownet.py
code served (permissive licence) · get_code("0fde1f9c55d73261")
How it ran

no invocation recorded.

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 1 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
binarize_static 1 other paper
1 dated earlier
2106.04399 (2021-06)
Flow Network based Generative Models for Non-Iterative Diverse Candidate Generation
sample 1 other paper
1 dated earlier
2106.04399 (2021-06)
Flow Network based Generative Models for Non-Iterative Diverse Candidate Generation
sleep_step 1 other paper
1 dated earlier
2106.04399 (2021-06)
Flow Network based Generative Models for Non-Iterative Diverse Candidate Generation

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

Latent variable models (LVMs) with discrete compositional latents are an important but challenging setting due to a combinatorially large number of possible configurations of the latents. A key tradeoff in modeling the posteriors over latents is between expressivity and tractable optimization. For algorithms based on expectationmaximization (EM), the E-step is often intractable without restrictive approximations to the posterior. We propose the use of GFlowNets, algorithms for sampling from an unnormalized density by learning a stochastic policy for sequential construction of samples, for this intractable E-step. By training GFlowNets to sample from the posterior over latents, we take advantage of their strengths as amortized variational inference algorithms for complex distributions over discrete structures. Our approach, GFlowNet-EM, enables the training of expressive LVMs with discrete compositional latents, as shown by experiments on non-contextfree grammar induction and on images using discrete variational autoencoders (VAEs) without conditional independence enforced in the encoder.

For agents

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

get_harvested_code_for_paper("2302.06576")
get_code_for_paper("2302.06576")
have("2302.06576")

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

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

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

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

Connect an agent — have() is free.