SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1611.01144 · 2016

Categorical Reparameterization with Gumbel-Softmax

Ben Poole, Eric Jang, Shixiang Gu

arXiv · PDF · Open in the Atlas

Code that ran

12 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 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; 8 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/1611.01144.json · badge: /api/ran/1611.01144.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
hellolzc/SBN_gumbel community
Papers with Code archive
3 ran · 0 no recorded run
chijames/gst community
Papers with Code archive
3 ran · 0 no recorded run
EdoardoBotta/Gaussian-Mixture-VAE community
Papers with Code archive
2 ran · 0 no recorded run
OlivierAlgoet/Tensorflow2-GMM community
Papers with Code archive
1 ran · 0 no recorded run
karpathy/deep-vector-quantization community
Papers with Code archive
1 ran · 0 no recorded run
jariasf/gmvae community
Papers with Code archive
1 ran · 0 no recorded run
kampta/pytorch-distributions community
Papers with Code archive
1 ran · 0 no recorded run
GuyLor/direct_vae community
Papers with Code archive
0 ran · 2 no recorded run
FunctionStatusWhere it lives
GMM Ran
ran on a synthesized input · constructed an object; no result was computed
OlivierAlgoet/Tensorflow2-GMM/src/GMM.py
code served (permissive licence) · get_code("dd897049a427c55d")
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 an instance of its own class, GMM: the run constructed the object and did not call it, so no result was computed. 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
import tensorflow as tf

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

# Define ARGS dictionary with parameters for GMM.__init__
ARGS = {
    'o_shape': 4,
    'K': 3,
    'gumbel_tau': 0.1,
    'name': 'test_gmm'
}
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 GMM — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GMM 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
GumbelQuantize Ran
ran on a synthesized input
karpathy/deep-vector-quantization/dvq/model/quantize.py
code served (permissive licence) · get_code("59b2d207600a31bf")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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
from torch import nn, einsum
import torch.nn.functional as F

class GumbelQuantize(nn.Module):
    """
    Gumbel Softmax trick quantizer
    Categorical Reparameterization with Gumbel-Softmax, Jang et al. 2016
    https://arxiv.org/abs/1611.01144
    """

    def __init__(self, num_hiddens, n_embed, embedding_dim, straight_through=False):
        super().__init__()
        self.embedding_dim = embedding_dim
        self.n_embed = n_embed
        self.straight_through = straight_through
        self.temperature = 1.0
        self.kld_scale = 0.0005
        self.proj = nn.Conv2d(num_hiddens, n_embed, 1)
        self.embed = nn.Embedding(n_embed, embedding_dim)

    def forward(self, z):
        hard = self.straight_through if self.training else True
        logits = self.proj(z)
        soft_one_hot = F.gumbel_softmax(logits, tau=self.temperature, dim=1, hard=hard)
        z_q = einsum('b n h w, n d -> b d h w', soft_one_hot, self.embed.weight)
        qy = F.softmax(logits, dim=1)
        diff = self.kld_scale * torch.sum(qy * torch.log(qy * self.n_embed + 1e-10), dim=1).mean()
        ind = soft_one_hot.argmax(dim=1)
        return (z_q, diff, ind)


INIT_ARGS = {
    'num_hiddens': 8,
    'n_embed': 4,
    'embedding_dim': 6,
    'straight_through': False,
}

ARGS = {
    'z': torch.randn(2, 8, 3, 5),
}

if __name__ == '__main__':
    model = GumbelQuantize(**INIT_ARGS)
    model.eval()
    output = model(**ARGS)
    print("Output shapes:")
    print(f"  z_q: {output[0].shape}")
    print(f"  diff: {output[1].shape}")
    print(f"  ind: {output[2].shape}")
    print("Success!")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
GumbelSoftmax Ran
ran on a synthesized input · constructed an object; no result was computed
jariasf/gmvae/pytorch/networks/Layers.py
code served (permissive licence) · get_code("3181ff255bf198ec")
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 an instance of its own class, GumbelSoftmax: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
from torch import nn

torch.manual_seed(0)

# Set up arguments for GumbelSoftmax
f_dim = 4
c_dim = 3

# Create instance for forward call
model = nn.Module()

# Create sample input tensor for forward pass
# Shape: (batch_size, f_dim) = (2, 4)
x = torch.randn(2, f_dim)

ARGS = {
    "f_dim": f_dim,
    "c_dim": c_dim,
}
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 GumbelSoftmax — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GumbelSoftmax 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
VAE Ran
ran on a synthesized input
kampta/pytorch-distributions/concrete_vae.py
pointer only (licence: NONE) · get_code("e87691ecef7118db")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, kampta/pytorch-distributions 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.

_gumbel_softmax_sample Ran
ran; our contract draft was wrong, not the code
hellolzc/SBN_gumbel/gumbel_sigmoid_softmax.py
code served (permissive licence) · get_code("a41fecd8dcdc493a")
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 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)

# Construct arguments for _gumbel_softmax_sample
logits = torch.randn(2, 4)  # batch_size=2, num_classes=4
temperature = 0.5

ARGS = {
    "logits": logits,
    "temperature": temperature,
}
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 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_gumbel Ran
ran; our contract draft was wrong, not the code
hellolzc/SBN_gumbel/gumbel_sigmoid_softmax.py
code served (permissive licence) · get_code("82f3a84259b22b4c")
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 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)

ARGS = {
    "shape": (2, 4),
    "eps": 1e-20,
    "device": 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 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
convert_to_one_hot Ran
ran; our contract draft was wrong, not the code
chijames/gst/model/basic.py
pointer only (licence: NONE) · get_code("ddba371fd54afdd0")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, chijames/gst 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.

gumbel_softmax Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
hellolzc/SBN_gumbel/gumbel_sigmoid_softmax.py
code served (permissive licence) · get_code("ae5d3a400d0e7968")
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)

# Create logits tensor: [batch_size=2, n_class=4]
logits = torch.randn(2, 4)

# temperature: non-negative scalar
temperature = 0.5

# hard: boolean flag
hard = False

ARGS = {
    "logits": logits,
    "temperature": temperature,
    "hard": hard,
}
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
gumbel_softmax_sample Ran
ran; our contract draft was wrong, not the code
EdoardoBotta/Gaussian-Mixture-VAE/distributions/gumbel.py
pointer only (licence: NONE) · get_code("d069f664a7cf326c")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, EdoardoBotta/Gaussian-Mixture-VAE 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.

masked_softmax Ran
ran; our contract draft was wrong, not the code
chijames/gst/model/basic.py
pointer only (licence: NONE) · get_code("c8b051f5575732d3")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, chijames/gst 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.

sample_gumbel Ran
ran; our contract draft was wrong, not the code
EdoardoBotta/Gaussian-Mixture-VAE/distributions/gumbel.py
pointer only (licence: NONE) · get_code("0df9e0f36c21548a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, EdoardoBotta/Gaussian-Mixture-VAE 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.

st_gumbel_softmax Ran
ran; our contract draft was wrong, not the code
chijames/gst/model/basic.py
pointer only (licence: NONE) · get_code("878b0d58fc1d164a")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, chijames/gst 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.

GSM_VAE Not yet run
unverified (harvested, no recorded run)
GuyLor/direct_vae/discrete_vae/GSM.py
pointer only (licence: NONE) · get_code("97c545c491659a35")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GuyLor/direct_vae 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.

VAE Not yet run
unverified (harvested, no recorded run)
GuyLor/direct_vae/discrete_vae/GSM.py
pointer only (licence: NONE) · get_code("1e08ae9c81b34087")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GuyLor/direct_vae 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.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 2 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 12 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
gumbel_softmax
brick of this paper's assembly: entry
1 other paper
1 dated earlier
1602.02830 (2016-02)
Binarized Neural Networks: Training Deep Neural Networks with Weights and Activations Constrained to +1 or -1
sample_gumbel
brick of this paper's assembly: helper
1 other paper
1 later
2405.04715 (2024-05)
Causality Pursuit from Heterogeneous Environments via Neural Adversarial Invariance 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-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Categorical variables are a natural choice for representing discrete structure in the world. However, stochastic neural networks rarely use categorical latent variables due to the inability to backpropagate through samples. In this work, we present an efficient gradient estimator that replaces the non-differentiable sample from a categorical distribution with a differentiable sample from a novel Gumbel-Softmax distribution. This distribution has the essential property that it can be smoothly annealed into a categorical distribution. We show that our Gumbel-Softmax estimator outperforms state-of-the-art gradient estimators on structured output prediction and unsupervised generative modeling tasks with categorical latent variables, and enables large speedups on semi-supervised classification.

For agents

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

get_harvested_code_for_paper("1611.01144")
get_code_for_paper("1611.01144")
have("1611.01144")

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

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

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

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

Connect an agent — have() is free.