SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.01440 · 2021

Memory Wrap: a Data-Efficient and Interpretable Extension to Image Classification Models

arXiv · PDF · Open in the Atlas

Code that ran

11 of 11 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 9 have no contract verdict; 2 failures of our instrument; 0 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/2106.01440.json · badge: /api/ran/2106.01440.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
KRLGroup/memory-wrap canonical (classifier label)
classifier basis: census
11 ran · 0 no recorded run
FunctionStatusWhere it lives
drop_connect Ran
ran; our contract draft was wrong, not the code
KRLGroup/memory-wrap/paper/architectures/efficientnet.py
pointer only (licence: MIT); the stored copy get_code serves, from EnumaCaliber/BRIDGE, is pointer only (licence: NONE) · get_code("4304a326c593f8db")
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 EnumaCaliber/BRIDGE, 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.

get_explanation_accuracy Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/explanation_accuracy.py
code served (permissive licence) · get_code("336b26ec3a7c916c")
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 torch.utils.data import DataLoader, TensorDataset

torch.manual_seed(0)

# Build a minimal model that satisfies the function's usage
class ExplanationModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc = nn.Linear(4, 3)  # 4 input features, 3 output classes
    
    def forward(self, data, memory, return_weights=False):
        # data shape: (batch_size, 4)
        # memory shape: (batch_size, 4)
        output = self.fc(data)  # (batch_size, 3)
        
        if return_weights:
            # Return output and weights (batch_size, batch_size)
            # Weights represent similarity/attention to memory samples
            batch_size = data.shape[0]
            mem_size = memory.shape[0]
            weights = torch.rand(batch_size, mem_size)  # (batch_size, mem_size)
            return output, weights
        
        return output

# Create small tensors for testing
batch_size = 2
feature_dim = 4
num_classes = 3
memory_size = 2

# Test data loader
test_data = torch.randn(batch_size, feature_dim)
test_targets = torch.randint(0, num_classes, (batch_size,))
test_dataset = TensorDataset(test_data, test_targets)
loader = DataLoader(test_dataset, batch_size=batch_size)

# Memory data loader
mem_data = torch.randn(memory_size, feature_dim)
mem_targets = torch.randint(0, num_classes, (memory_size,))
mem_dataset = TensorDataset(mem_data, mem_targets)
mem_loader = DataLoader(mem_dataset, batch_size=memory_size)

# Create model and move to device
device = torch.device('cpu')
model = ExplanationModel()
model = model.to(device)

ARGS = {
    'model': model,
    'loader': loader,
    'mem_loader': mem_loader,
    'device': device
}
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, 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
major_voting_baseline Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/eval_dir_mv.py
code served (permissive licence) · get_code("054756e8a316dc45")
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 torch.utils.data import DataLoader, TensorDataset

torch.manual_seed(0)

# Create a small model that mimics the expected behavior
class MemoryWrapModel(nn.Module):
    def __init__(self, input_dim=4, num_classes=3, memory_dim=4):
        super().__init__()
        self.fc1 = nn.Linear(input_dim + memory_dim, 64)
        self.fc2 = nn.Linear(64, num_classes)
        self.weight_fc = nn.Linear(64, 1)
    
    def forward(self, data, memory, return_weights=False):
        # Concatenate data and memory
        combined = torch.cat([data, memory], dim=1)
        hidden = torch.relu(self.fc1(combined))
        logits = self.fc2(hidden)
        
        if return_weights:
            weights = torch.sigmoid(self.weight_fc(hidden))
            return logits, weights
        return logits

# Create tiny tensors for test data
# batch_size=2, input_dim=4, num_classes=3
test_data = torch.randn(2, 4)
test_targets = torch.randint(0, 3, (2,))

# Create memory data
mem_data = torch.randn(2, 4)
mem_targets = torch.randint(0, 3, (2,))

# Create DataLoaders
test_dataset = TensorDataset(test_data, test_targets)
mem_dataset = TensorDataset(mem_data, mem_targets)

test_loader = DataLoader(test_dataset, batch_size=2, shuffle=False)
mem_loader = DataLoader(mem_dataset, batch_size=2, shuffle=False)

# Create model and loss
model = MemoryWrapModel(input_dim=4, num_classes=3, memory_dim=4)
model.eval()

loss_criterion = nn.CrossEntropyLoss()
device = torch.device('cpu')

# Move model to device
model = model.to(device)

ARGS = {
    'model': model,
    'loader': test_loader,
    'mem_loader': mem_loader,
    'loss_criterion': loss_criterion,
    'device': device
}
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, 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
set_seed Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/VIT/train_memory_vit.py
code served (permissive licence) · get_code("556d97d0147c715d")
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. 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
import numpy as np
import random
import os

# Set a base seed for reproducibility of the setup code itself
torch.manual_seed(0)
np.random.seed(0)
random.seed(0)

# The function takes a single parameter: seed (int)
# Looking at the function body, it only uses the seed value
# to set various random number generators

ARGS = {
    "seed": 42
}
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 — 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
split_dataset Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/VIT/train_memory_vit.py
code served (permissive licence) · get_code("396cfa296f2b6833")
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.utils.data

torch.manual_seed(0)

# Create a minimal custom dataset
class SimpleDataset(torch.utils.data.Dataset):
    def __init__(self, size: int):
        self.size = size
    
    def __len__(self):
        return self.size
    
    def __getitem__(self, idx: int):
        return torch.randn(4), idx

# Construct the dataset with enough samples for both train and val splits
dataset = SimpleDataset(size=100)

# Define arguments
ARGS = {
    "dataset": dataset,
    "train_size": 60,
    "val_size": 20,
    "seed": 42
}
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
swish Ran
ran; our contract draft was wrong, not the code
KRLGroup/memory-wrap/paper/architectures/efficientnet.py
pointer only (licence: MIT); the stored copy get_code serves, from EnumaCaliber/BRIDGE, is pointer only (licence: NONE) · get_code("8737c82de631cffc")
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 EnumaCaliber/BRIDGE, 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.

undo_normalization_CIFAR10 Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/datasets.py
code served (permissive licence) · get_code("30e4e5a2d89e2664")
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, 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
import torchvision

torch.manual_seed(0)

# Create a small normalized image tensor for CIFAR10
# CIFAR10 images are 3-channel (RGB), so we need shape (batch, channels, height, width)
# Using batch=2, channels=3, height=4, width=4 for a tiny test image
input_tensor = torch.randn(2, 3, 4, 4)

# Normalize it first to simulate a real CIFAR10 image
mean = [0.4914, 0.4822, 0.4465]
std = [0.2023, 0.1994, 0.201]
normalize = torchvision.transforms.Normalize(mean=mean, std=std)
input_tensor = normalize(input_tensor)

ARGS = {
    "input": input_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — 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, 4) — shape (2, 3, 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
undo_normalization_CINIC10 Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/datasets.py
code served (permissive licence) · get_code("edcd76ca7ab8dd93")
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, 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
import torchvision

torch.manual_seed(0)

# Create a small normalized image tensor
# Shape: (batch_size=2, channels=3, height=4, width=4)
# Values in range [0, 1] representing normalized images
input_tensor = torch.rand(2, 3, 4, 4)

ARGS = {
    "input": input_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — 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, 4) — shape (2, 3, 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
undo_normalization_SVHN Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/datasets.py
code served (permissive licence) · get_code("34c08d4c54fc20d2")
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, 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
import torchvision

torch.manual_seed(0)

# Create a small normalized image tensor
# Shape: (batch=2, channels=3, height=4, width=4)
input_tensor = torch.randn(2, 3, 4, 4)

ARGS = {
    "input": input_tensor
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — 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, 4) — shape (2, 3, 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
wrn28_10 Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/architectures/wide_resnet.py
code served (permissive licence) · get_code("7ac8b84a748525a0")
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 Wide_ResNet. 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)

ARGS = {
    'num_classes': 10,
    'dropout': 0.3,
}
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 Wide_ResNet — a Wide_ResNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Wide_ResNet 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
wrn28_2 Ran
ran on a synthesized input
KRLGroup/memory-wrap/paper/architectures/wide_resnet.py
code served (permissive licence) · get_code("e98169cd39e1845e")
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 Wide_ResNet. 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)

ARGS = {
    "num_classes": 10,
    "dropout": 0.3,
}
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 Wide_ResNet — a Wide_ResNet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Wide_ResNet 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

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 2 the same month, 2 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
swish 32 other papers
2 dated earlier, 1 the same month, 29 later
1512.03385 (2015-12)
Deep Residual Learning for Image Recognition
2002.11318 (2020-02)
Can we have it all? On the Trade-off between Spatial and Adversarial Robustness of Neural Networks
2106.10807 (2021-06)
Adversarial Examples Make Strong Poisons
and 29 more not named here
drop_connect 29 other papers
4 dated earlier, 1 the same month, 24 later
1512.03385 (2015-12)
Deep Residual Learning for Image Recognition
1905.11946 (2019-05)
EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks
2002.09564 (2020-02)
Towards Robust and Reproducible Active Learning Using Neural Networks
and 26 more not named here

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

Due to their black-box and data-hungry nature, deep learning techniques are not yet widely adopted for real-world applications in critical domains, like healthcare and justice. This paper presents Memory Wrap, a plug-and-play extension to any image classification model. Memory Wrap improves both data-efficiency and model interpretability, adopting a content-attention mechanism between the input and some memories of past training samples. We show that Memory Wrap outperforms standard classifiers when it learns from a limited set of data, and it reaches comparable performance when it learns from the full dataset. We discuss how its structure and content-attention mechanisms make predictions interpretable, compared to standard classifiers. To this end, we both show a method to build explanations by examples and counterfactuals, based on the memory content, and how to exploit them to get insights about its decision process. We test our approach on image classification tasks using several architectures on three different datasets, namely CIFAR10, SVHN, and CINIC10.

For agents

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

get_harvested_code_for_paper("2106.01440")
get_code_for_paper("2106.01440")
have("2106.01440")

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

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

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

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

Connect an agent — have() is free.