SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · aaai_27804 · AAAI · 2024

Enhancing the Robustness of Spiking Neural Networks with Stochastic Gating Mechanisms

Tiejun Huang, Zhaofei Yu, Jianhao Ding, Jian Liu

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 5 have no contract verdict; 2 failures of our instrument; 3 no recorded run), measured 2026-11-22; 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/aaai_27804.json · badge: /api/ran/aaai_27804.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
DingJianhao/StoG-meets-SNN canonical (classifier label)
classifier basis: census
7 ran · 3 no recorded run
FunctionStatusWhere it lives
BPTT_attack Ran
ran on a synthesized input
DingJianhao/StoG-meets-SNN/functions.py
code served (permissive licence) · get_code("37dabb02063fbef7")
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, 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 torch
import torch.nn as nn

torch.manual_seed(0)

class SimpleRNNModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self.T_set = None
        self.mode_set = None
    
    def set_simulation_time(self, T=None, mode=None):
        self.T_set = T
        self.mode_set = mode
    
    def forward(self, x):
        # x shape: (batch, time_steps, features) or (batch, features)
        # Return shape: (time_steps, batch, output_features)
        if x.dim() == 2:
            x = x.unsqueeze(1)  # Add time dimension if needed
        output = self.linear(x)  # (batch, time_steps, 3)
        output = output.transpose(0, 1)  # (time_steps, batch, 3)
        return output

model = SimpleRNNModel()

# Create a small image tensor: (batch=2, features=4)
image = torch.randn(2, 4)

ARGS = {
    'model': model,
    'image': image,
    'T': 5
}
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, 3) — shape (2, 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
RateBP_attack Ran
ran on a synthesized input
DingJianhao/StoG-meets-SNN/functions.py
code served (permissive licence) · get_code("80c79b11e0f6ef7d")
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, 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 torch
import torch.nn as nn

torch.manual_seed(0)

class MockSpikeModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
        self._T = None
        self._mode = None
    
    def set_simulation_time(self, T=None, mode=None):
        self._T = T
        self._mode = mode
    
    def forward(self, x):
        # Return output with time dimension: (T, batch, features)
        # T=5 timesteps, batch=2, output_features=3
        batch_size = x.shape[0]
        output = self.linear(x)  # (batch, 3)
        # Expand to (T, batch, 3) by repeating over time
        return output.unsqueeze(0).expand(5, batch_size, 3)

model = MockSpikeModel()
image = torch.randn(2, 4)  # batch_size=2, input_dim=4

ARGS = {
    'model': model,
    'image': image,
    'T': 5
}
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, 3) — shape (2, 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
add_dimention Ran
ran on a synthesized input
DingJianhao/StoG-meets-SNN/models/layers.py
code served (permissive licence) · get_code("9cf36371054291c9")
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 5, dtype family float, shape (6, 1, 3, 4, 5) 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 4D tensor with batch size 2 and feature dimension 4
# Shape: (batch=2, height=3, width=4, channels=5)
x = torch.randn(2, 3, 4, 5)

# T is an integer representing the repetition factor
T = 3

ARGS = {
    "x": x,
    "T": T
}
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 5, dtype family float, shape (6, 1, 3, 4, 5) — shape (6, 1, 3, 4, 5) 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_logger Ran
ran; our contract draft was wrong, not the code
DingJianhao/StoG-meets-SNN/functions.py
pointer only (licence: MIT); the stored copy get_code serves, from hzc1208/lmht_snn, is pointer only (licence: NONE) · get_code("210ba8a40d178d14")
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 hzc1208/lmht_snn, 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. A run is recorded.

normalizex Ran
ran; our contract draft was wrong, not the code
DingJianhao/StoG-meets-SNN/models/layers.py
pointer only (licence: MIT); the stored copy get_code serves, from bollossom/GAC, is pointer only (licence: NONE) · get_code("a93504b7fd3c8d98")
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 bollossom/GAC, 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. A run is recorded.

val Ran
ran on a synthesized input
DingJianhao/StoG-meets-SNN/sparse_code_utils.py
code served (permissive licence) · get_code("e59d4d3fabd87987")
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
from unittest.mock import Mock

torch.manual_seed(0)

# Build a minimal model that supports .eval() and forward pass
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 10)
    
    def forward(self, x):
        # Model expects input and returns output with batch dimension
        # The function calls .mean(0) on outputs, so we need to return
        # a tensor that can be reduced that way
        out = self.linear(x)
        # Return shape (num_samples, batch_size, num_classes) to support .mean(0)
        return out.unsqueeze(0)

# Build a minimal representation function
class RepresentationModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, x):
        return self.linear(x)

# Build a minimal attack object
class MinimalAttack:
    def __init__(self):
        self.targeted = False
        self.model = Mock()
        self.model.set_simulation_time = Mock()
    
    def __call__(self, x, y):
        # Return perturbed input
        return x + 0.01 * torch.randn_like(x)
    
    def set_training_mode(self, model_training=False, batchnorm_training=False, dropout_training=False):
        pass

# Create test loader as list of (inputs, targets) tuples
test_loader = [
    (torch.randn(2, 4), torch.randint(0, 10, (2,))),
    (torch.randn(2, 4), torch.randint(0, 10, (2,))),
]

# Build components
model = SimpleModel()
representation = RepresentationModel()
device = 'cpu'
atk = MinimalAttack()

ARGS = {
    'model': model,
    'test_loader': test_loader,
    'device': device,
    'representation': representation,
    'T': 5,
    'atk': atk,
    'num_targets': 10,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
val Ran
ran on a synthesized input
DingJianhao/StoG-meets-SNN/utils.py
code served (permissive licence) · get_code("677ba1186b7388df")
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 float, 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)

# Build a minimal model that satisfies the function's usage
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)  # 4 input features, 3 classes
        self.T = 0
    
    def forward(self, x):
        # When T > 0, the function expects outputs.mean(0) to work
        # This suggests outputs should be [T, batch, num_classes] or similar
        # For simplicity, return [batch, num_classes] which mean(0) will handle
        return self.linear(x)
    
    def set_simulation_time(self, T):
        self.T = T
    
    def eval(self):
        super().eval()
        return self

# Build a minimal attack object that satisfies the function's usage
class MinimalAttack:
    def __call__(self, inputs, targets):
        # Attack should return perturbed inputs of same shape
        return inputs + 0.01 * torch.randn_like(inputs)
    
    def set_training_mode(self, model_training=False, batchnorm_training=False, dropout_training=False):
        pass

# Create test loader as list of (inputs, targets) tuples
test_loader = [
    (torch.randn(2, 4), torch.randint(0, 3, (2,))),
    (torch.randn(2, 4), torch.randint(0, 3, (2,))),
]

ARGS = {
    "model": MinimalModel(),
    "test_loader": test_loader,
    "device": torch.device("cpu"),
    "T": 0,
    "atk": MinimalAttack(),
    "representation": 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 float, 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
build_cifar Not yet run
unverified (harvested, no recorded run)
DingJianhao/StoG-meets-SNN/data_loaders.py
code served (permissive licence) · get_code("f590d512f3f231c9")
How it ran

no invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
DingJianhao/StoG-meets-SNN/utils.py
code served (permissive licence) · get_code("2146c08c33292789")
How it ran

no invocation recorded.

train_mix Not yet run
unverified (harvested, no recorded run)
DingJianhao/StoG-meets-SNN/utils.py
code served (permissive licence) · get_code("88074ece54c53853")
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, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 0 the same month, 1 later) and 8 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_logger 10 other papers
5 dated earlier, 2 later, 3 same year, order not determinable
2106.06716 (2021-06)
DS-TransUNet:Dual Swin Transformer U-Net for Medical Image Segmentation
2205.08987 (2022-05)
Trading Positional Complexity vs Deepness in Coordinate Networks
2207.00012 (2022-07)
Reliable Representations Make A Stronger Defender: Unsupervised Structure Refinement for Robust GNN
and 7 more not named here
normalizex 3 other papers
3 dated earlier
2202.11946 (2022-02)
Temporal Efficient Training of Spiking Neural Network via Gradient Re-weighting
2304.13098 (2023-04)
Uncovering the Representation of Spiking Neural Networks Trained with Surrogate Gradient
2308.06582 (2023-08)
Gated Attention Coding for Training High-performance and Efficient Spiking Neural Networks

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

Spiking neural networks (SNNs) exploit neural spikes to provide solutions for low-power intelligent applications on neuromorphic hardware. Although SNNs have high computational efficiency due to spiking communication, they still lack resistance to adversarial attacks and noise perturbations. In the brain, neuronal responses generally possess stochasticity induced by ion channels and synapses, while the role of stochasticity in computing tasks is poorly understood. Inspired by this, we elaborate a stochastic gating spiking neural model for layer-by-layer spike communication, introducing stochasticity to SNNs. Through theoretical analysis, our gating model can be viewed as a regularizer that prevents error amplification under attacks. Meanwhile, our work can explain the robustness of Poisson coding. Experimental results prove that our method can be used alone or with existing robust enhancement algorithms to improve SNN robustness and reduce SNN energy consumption. We hope our work will shed new light on the role of stochasticity in the computation of SNNs. Our code is available at https://github.com/DingJianhao/StoG-meets-SNN/.

For agents

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

get_harvested_code_for_paper("aaai_27804")
get_code_for_paper("aaai_27804")
have("aaai_27804")

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

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

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

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

Connect an agent — have() is free.