SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2303.15564 · 2023

Mask and Restore: Blind Backdoor Defense at Test Time with Masked Autoencoder

arXiv · PDF · Open in the Atlas

Code that ran

8 of 15 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; 1 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 1 failure of our instrument; 7 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/2303.15564.json · badge: /api/ran/2303.15564.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
tsun/bdmae canonical (classifier label)
classifier basis not recorded on the link
8 ran · 7 no recorded run
FunctionStatusWhere it lives
Februus_GTSRB Ran
ran on a synthesized input
tsun/bdmae/models/februus.py
code served (permissive licence) · get_code("66cb9e0f5d3c2483")
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 GTSRB. 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

torch.manual_seed(0)

# The function Februus_GTSRB takes a single parameter: n_channel
# It uses n_channel to build a configuration and create a GTSRB model
# We need to provide a valid n_channel value

ARGS = {
    "n_channel": 16
}
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 GTSRB — a GTSRB output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a GTSRB 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
Februus_cifar10 Ran
ran on a synthesized input
tsun/bdmae/models/februus.py
code served (permissive licence) · get_code("44b42f1277dd9e3b")
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 CIFAR. 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

torch.manual_seed(0)

# The function Februus_cifar10 takes one parameter: n_channel
# Looking at the function body:
# - n_channel is used to construct a cfg list with multiples of it
# - cfg is passed to make_layers
# - The final model uses n_channel=4 * n_channel * 4 * 4 for the classifier
# - num_classes is hardcoded to 10

# We need to pick a reasonable n_channel value
n_channel_value = 8

ARGS = {
    "n_channel": n_channel_value
}
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 CIFAR — a CIFAR output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a CIFAR 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
create_targets_bd Ran
ran on a synthesized input
tsun/bdmae/attack/inputaware_attack.py
code served (permissive licence) · get_code("c296d9923af6a494")
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 int, shape (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)

class OptConfig:
    def __init__(self):
        self.attack_mode = 'all2one'
        self.attack_target = 3
        self.num_classes = 5
        self.device = 'cpu'

targets = torch.tensor([0, 1, 2, 1], dtype=torch.long)
opt = OptConfig()

ARGS = {
    'targets': targets,
    'opt': opt
}
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 int, shape (4,) — shape (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
create_window Ran
ran on a synthesized input
tsun/bdmae/defense/pytorch_ssim.py
code served (permissive licence) · get_code("48b9ca43caa5a8d6")
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 4, dtype family float, shape (3, 1, 5, 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
from math import exp

torch.manual_seed(0)

def gaussian(window_size, sigma):
    gauss = torch.Tensor([exp(-(x - window_size // 2) ** 2 / float(2 * sigma ** 2)) for x in range(window_size)])
    return gauss / gauss.sum()

def create_window(window_size, channel, sigma=1.5):
    _1D_window = gaussian(window_size, sigma).unsqueeze(1)
    _2D_window = _1D_window.mm(_1D_window.t()).float().unsqueeze(0).unsqueeze(0)
    window = torch.Tensor(_2D_window.expand(channel, 1, window_size, window_size).contiguous())
    return window

ARGS = {
    "window_size": 5,
    "channel": 3,
    "sigma": 1.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 4, dtype family float, shape (3, 1, 5, 5) — shape (3, 1, 5, 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
gaussian Ran
ran, honoured the contract we drafted
tsun/bdmae/defense/pytorch_ssim.py
code served (permissive licence) · get_code("c56b7ef16f309a45")
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 1, dtype family float, shape (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
from math import exp

torch.manual_seed(0)

ARGS = {
    "window_size": 5,
    "sigma": 1.0,
}
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 1, dtype family float, shape (5,) — shape (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
make_layers Ran
ran on a synthesized input
tsun/bdmae/models/februus.py
code served (permissive licence) · get_code("6470f17e85b4a1aa")
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 Sequential. 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

torch.manual_seed(0)

# Construct cfg - a list containing Conv2d specifications and pooling markers
# Each element can be:
# - 'M' or 'M1': MaxPool2d marker
# - An integer: out_channels (with default padding=1)
# - A tuple: (out_channels, padding)

cfg = [
    64,           # Conv2d with 64 out_channels, default padding=1
    (128, 2),     # Conv2d with 128 out_channels, padding=2
    'M',          # MaxPool2d
    256,          # Conv2d with 256 out_channels, default padding=1
    'M1',         # MaxPool2d
    (512, 1),     # Conv2d with 512 out_channels, padding=1
]

ARGS = {
    'cfg': cfg,
    'batch_norm': 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 Sequential — a Sequential output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Sequential output the recorded ndim 1 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
poisson_blend_old Ran
ran on a synthesized input
tsun/bdmae/defense/Februus.py
code served (permissive licence) · get_code("7f8ea158f543bdb1")
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 4, dtype family float, shape (2, 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
import numpy as np

torch.manual_seed(0)

# Create small tensors with distinct dimensions for clarity
batch_size = 2
channels = 3
height = 4
width = 5

# input: (batch, channels, height, width) - the original image
input_tensor = torch.randn(batch_size, channels, height, width)

# output: (batch, channels, height, width) - the completed/inpainted image
output_tensor = torch.randn(batch_size, channels, height, width)

# mask: (batch, 1, height, width) - binary mask where 1 indicates inpainted region
mask_tensor = torch.randint(0, 2, (batch_size, 1, height, width)).float()

ARGS = {
    'input': input_tensor,
    'output': output_tensor,
    'mask': mask_tensor,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, 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 4, dtype family float, shape (2, 3, 4, 5) — shape (2, 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
ssim Ran
ran; our contract draft was wrong, not the code
tsun/bdmae/defense/pytorch_ssim.py
code served (permissive licence) · get_code("d0b60b04b5634496")
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 3, dtype family float, shape (2, 4, 4) as a later run recorded it. 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, 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.functional as F
from math import exp

torch.manual_seed(0)

# Create two small image tensors: batch_size=2, channels=3, height=4, width=4
img1 = torch.randn(2, 3, 4, 4)
img2 = torch.randn(2, 3, 4, 4)

# window_size parameter
window_size = 11

# size_average parameter
size_average = True

ARGS = {
    "img1": img1,
    "img2": img2,
    "window_size": window_size,
    "size_average": size_average,
}
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 3, dtype family float, shape (2, 4, 4) — shape (2, 4, 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
add_args Not yet run
unverified (harvested, no recorded run)
tsun/bdmae/attack/lc_attack.py
code served (permissive licence) · get_code("5394691602c74e1b")
How it ran

no invocation recorded.

add_args Not yet run
unverified (harvested, no recorded run)
tsun/bdmae/attack/badnet_attack.py
code served (permissive licence) · get_code("47506a60457acdcf")
How it ran

no invocation recorded.

fine_tuning Not yet run
unverified (harvested, no recorded run)
tsun/bdmae/defense/ft.py
code served (permissive licence) · get_code("8ade85bc4607042e")
How it ran

no invocation recorded.

get_1d_sincos_pos_embed_from_grid Not yet run
unverified (harvested, no recorded run)
tsun/bdmae/mae/pos_embed.py
pointer only (licence: MIT); the stored copy get_code serves, from zhangyifei01/LMIM, is pointer only (licence: NONE) · get_code("12035a2f77d8016c")
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 zhangyifei01/LMIM, 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.

get_2d_sincos_pos_embed Not yet run
unverified (harvested, no recorded run)
tsun/bdmae/mae/pos_embed.py
pointer only (licence: MIT); the stored copy get_code serves, from yunongLiu1/IKEA-Manuals-at-Work, is pointer only (licence: NONE) · get_code("3185afc3e87293ed")
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 yunongLiu1/IKEA-Manuals-at-Work, 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.

get_2d_sincos_pos_embed_from_grid Not yet run
unverified (harvested, no recorded run)
tsun/bdmae/mae/pos_embed.py
pointer only (licence: MIT); the stored copy get_code serves, from zhangyifei01/LMIM, is pointer only (licence: NONE) · get_code("f10004e059714d42")
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 zhangyifei01/LMIM, 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.

newblend Not yet run
unverified (harvested, no recorded run)
tsun/bdmae/defense/Februus.py
code served (permissive licence) · get_code("c56a11461aa35268")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 distinct functions with an identity, 6 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 5 the same month, 5 later) and 9 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_2d_sincos_pos_embed_from_grid 190 other papers
25 dated earlier, 7 the same month, 157 later, 1 same year, order not determinable · 65 only as an assembly brick
1807.10221 (2018-07)
Unified Perceptual Parsing for Scene Understanding
2105.12723 (2021-05)
Nested Hierarchical Transformer: Towards Accurate, Data-Efficient and Interpretable Visual Understanding
2111.06377 (2021-11)
Masked Autoencoders Are Scalable Vision Learners
and 187 more not named here
gaussian 160 other papers
37 dated earlier, 2 the same month, 119 later, 2 same year, order not determinable · 7 only as an assembly brick
1812.11941 (2018-12)
High Quality Monocular Depth Estimation via Transfer Learning
1904.01538 (2019-04)
Spatial Attentive Single-Image Deraining with a High Quality Real Rain Dataset
1907.11628 (2019-07)
Unsupervised Learning for Optical Flow Estimation Using Pyramid Convolution LSTM
and 157 more not named here
get_2d_sincos_pos_embed 95 other papers
20 dated earlier, 3 the same month, 71 later, 1 same year, order not determinable · 33 only as an assembly brick
1807.10221 (2018-07)
Unified Perceptual Parsing for Scene Understanding
2105.12723 (2021-05)
Nested Hierarchical Transformer: Towards Accurate, Data-Efficient and Interpretable Visual Understanding
2111.06377 (2021-11)
Masked Autoencoders Are Scalable Vision Learners
and 92 more not named here
get_1d_sincos_pos_embed_from_grid 39 other papers
15 dated earlier, 2 the same month, 21 later, 1 same year, order not determinable · 25 only as an assembly brick
2105.12723 (2021-05)
Nested Hierarchical Transformer: Towards Accurate, Data-Efficient and Interpretable Visual Understanding
2111.06377 (2021-11)
Masked Autoencoders Are Scalable Vision Learners
2204.09435 (2022-04)
Hephaestus: A large scale multitask dataset towards InSAR understanding
and 36 more not named here
ssim 28 other papers
8 dated earlier, 1 the same month, 18 later, 1 same year, order not determinable
1904.01538 (2019-04)
Spatial Attentive Single-Image Deraining with a High Quality Real Rain Dataset
1907.11628 (2019-07)
Unsupervised Learning for Optical Flow Estimation Using Pyramid Convolution LSTM
2002.11616 (2020-02)
Zooming Slow-Mo: Fast and Accurate One-Stage Space-Time Video Super-Resolution
and 25 more not named here
add_args 1 other paper
1 same year, order not determinable
Pang_Backdoor_Cleansing_With_Unlabeled_Data_CVPR_2023_paper (2023 (year only))
Backdoor Cleansing with Unlabeled Data

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

Deep neural networks are vulnerable to backdoor attacks, where an adversary manipulates the model behavior through overlaying images with special triggers. Existing backdoor defense methods often require accessing a few validation data and model parameters, which is impractical in many real-world applications, e.g., when the model is provided as a cloud service. In this paper, we address the practical task of blind backdoor defense at test time, in particular for local attacks and black-box models. The true label of every test image needs to be recovered on the fly from a suspicious model regardless of image benignity. We consider test-time image purification that incapacitates local triggers while keeping semantic contents intact. Due to diverse trigger patterns and sizes, the heuristic trigger search can be unscalable. We circumvent such barrier by leveraging the strong reconstruction power of generative models, and propose Blind Defense with Masked AutoEncoder (BDMAE). BDMAE detects possible local triggers using image structural similarity and label consistency between the test image and MAE restorations. The detection results are then refined by considering trigger topology. Finally, we fuse MAE restorations adaptively into a purified image for making prediction. Extensive experiments under different backdoor settings validate its effectiveness and generalizability.

For agents

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

get_harvested_code_for_paper("2303.15564")
get_code_for_paper("2303.15564")
have("2303.15564")

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

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

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

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

Connect an agent — have() is free.