SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1703.05175 · NeurIPS · 2017

Prototypical Networks for Few-shot Learning

Richard Zemel, Jake Snell

arXiv · PDF · Open in the Atlas

Code that ran

50 of 64 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (14 of them constructed an object rather than computing a result; 5 honoured the contract we drafted, 0 violated it and 24 have no contract verdict; 21 failures of our instrument; 14 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/1703.05175.json · badge: /api/ran/1703.05175.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
DrMMZ/ProtoNet community
Papers with Code archive
6 ran · 3 no recorded run
joshfp/one-shot-learning community
Papers with Code archive
3 ran · 1 no recorded run
sicara/easy-few-shot-learning community
not in the paper's declared repositories
3 ran · 0 no recorded run
akshatgarg99/FewShotLearning community
Papers with Code archive
3 ran · 0 no recorded run
oscarknagg/few-shot community
not in the paper's declared repositories
3 ran · 0 no recorded run
jsalbert/prototypical-networks community (classifier label)
classifier basis: plan_row
2 ran · 2 no recorded run
cyvius96/prototypical-network-pytorch community
Papers with Code archive
2 ran · 0 no recorded run
andrewbo29/mtm-meta-learning-sa community
Papers with Code archive
2 ran · 0 no recorded run
maxstrobel/HCN-PrototypeLoss-PyTorch community
Papers with Code archive
2 ran · 0 no recorded run
ulises-jeremias/prototypical-networks-tf community
not in the paper's declared repositories
2 ran · 0 no recorded run
learnables/learn2learn community
not in the paper's declared repositories
2 ran · 0 no recorded run
copy not recorded community
not in the paper's declared repositories
2 ran · 0 no recorded run
minseop-aitrics/FewshotLearning community
Papers with Code archive
1 ran · 3 no recorded run
Hsankesara/DeepResearch community
Papers with Code archive
1 ran · 1 no recorded run
Sha-Lab/FEAT community
Papers with Code archive
1 ran · 1 no recorded run
lif31up/prototypical-network community
Papers with Code archive
1 ran · 1 no recorded run
RongKaiWeskerMA/INSTA community
Papers with Code archive
1 ran · 1 no recorded run
KamalM8/Few-Shot-learning-Fashion community
Papers with Code archive
1 ran · 1 no recorded run
HenryCWoo/LTLProject community
Papers with Code archive
1 ran · 0 no recorded run
amazon-research/dse community
Papers with Code archive
1 ran · 0 no recorded run
orobix/Prototypical-Networks-for-Few-shot-Learning-PyTorch community
Papers with Code archive
1 ran · 0 no recorded run
COAOX/Cifar-Prototypical community
Papers with Code archive
1 ran · 0 no recorded run
goldblum/AdversarialQuerying community
Papers with Code archive
1 ran · 0 no recorded run
jakesnell/prototypical-networks marked official in Papers with Code
Papers with Code archive
1 ran · 0 no recorded run
schatty/prototypical-networks-tf community
not in the paper's declared repositories
1 ran · 0 no recorded run
FunctionStatusWhere it lives
AccMetric Ran
ran on a synthesized input · constructed an object; no result was computed
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("5885c112f3046823")
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, AccMetric: 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 tensorflow as tf

# The AccMetric class takes only 'name' as a parameter
# The call method expects inputs as (y_true, y_pred) tuple
# y_true: integer labels (sparse categorical)
# y_pred: logits or probabilities

ARGS = {
    "name": "accuracy_metric"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type AccMetric — 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 AccMetric 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
CELoss Ran
ran on a synthesized input · constructed an object; no result was computed
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("e3a0222fd8ed2d2f")
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, CELoss: 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 tensorflow as tf

# CELoss.__init__ takes only 'name' parameter
# CELoss.call expects inputs to be (y_true, y_pred) tuple
# y_true: integer labels (sparse format)
# y_pred: logits or probabilities

# Create small test data
batch_size = 2
num_classes = 4

# y_true: sparse labels (integers), shape (batch_size,)
y_true = tf.constant([0, 2], dtype=tf.int64)

# y_pred: logits/predictions, shape (batch_size, num_classes)
y_pred = tf.constant([
    [1.0, 2.0, 0.5, -1.0],
    [0.2, -0.5, 1.5, 0.8]
], dtype=tf.float32)

inputs = (y_true, y_pred)

ARGS = {
    "name": None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CELoss — 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 CELoss 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
ConvNet Ran
ran on a synthesized input · constructed an object; no result was computed
HenryCWoo/LTLProject/models/convnet_mini.py
code served (permissive licence) · get_code("0c8ab3061fc4f61b")
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, ConvNet: 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 torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'x_dim': 3,
    'hid_dim': 64,
    'z_dim': 64,
}
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 ConvNet — 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 ConvNet 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
Convnet Ran
ran on a synthesized input · constructed an object; no result was computed
cyvius96/prototypical-network-pytorch/convnet.py
code served (permissive licence) · get_code("03ab81be46e41dfb")
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, Convnet: 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 torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'x_dim': 3,
    'hid_dim': 64,
    'z_dim': 64,
}
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 Convnet — 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 Convnet 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
EmbeddingFunction Ran
ran on a synthesized input
joshfp/one-shot-learning/model.py
pointer only (licence: NONE) · get_code("fe0021aa329ae860")
How it ran

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

FewShotClassifier Ran
ran on a synthesized input
sicara/easy-few-shot-learning/easyfsl/methods/prototypical_networks.py
code served (permissive licence) · get_code("f798e1a78274cb31")
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 Tensor, ndim 2, 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
from torch import nn, Tensor

# Define a simple backbone for feature extraction
class SimpleBackbone(nn.Module):
    def __init__(self, input_dim: int, output_dim: int):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
    
    def forward(self, x: Tensor) -> Tensor:
        return self.linear(x)

# Import the class to test
from torch import Tensor
from abc import abstractmethod
from typing import Optional
import torch
from torch import Tensor, nn

def compute_prototypes(support_features: Tensor, support_labels: Tensor) -> Tensor:
    """
    Compute class prototypes from support features and labels
    """
    n_way = len(torch.unique(support_labels))
    return torch.cat([support_features[torch.nonzero(support_labels == label)].mean(0) for label in range(n_way)])

class FewShotClassifier(nn.Module):
    """
    Abstract class providing methods usable by all few-shot classification algorithms
    """

    def __init__(self, backbone: Optional[nn.Module]=None, use_softmax: bool=False, feature_centering: Optional[Tensor]=None, feature_normalization: Optional[float]=None):
        super().__init__()
        self.backbone = backbone if backbone is not None else nn.Identity()
        self.use_softmax = use_softmax
        self.prototypes = torch.tensor(())
        self.support_features = torch.tensor(())
        self.support_labels = torch.tensor(())
        self.feature_centering = feature_centering if feature_centering is not None else torch.tensor(0)
        self.feature_normalization = feature_normalization

    @abstractmethod
    def forward(self, query_images: Tensor) -> Tensor:
        raise NotImplementedError('All few-shot algorithms must implement a forward method.')

    def process_support_set(self, support_images: Tensor, support_labels: Tensor):
        self.compute_prototypes_and_store_support_set(support_images, support_labels)

    @staticmethod
    def is_transductive() -> bool:
        raise NotImplementedError('All few-shot algorithms must implement a is_transductive method.')

    def compute_features(self, images: Tensor) -> Tensor:
        original_features = self.backbone(images)
        centered_features = original_features - self.feature_centering
        if self.feature_normalization is not None:
            return nn.functional.normalize(centered_features, p=self.feature_normalization, dim=1)
        return centered_features

    def softmax_if_specified(self, output: Tensor, temperature: float=1.0) -> Tensor:
        return (temperature * output).softmax(-1) if self.use_softmax else output

    def l2_distance_to_prototypes(self, samples: Tensor) -> Tensor:
        return torch.cdist(samples, self.prototypes)

# Create a concrete implementation for testing
class ConcreteClassifier(FewShotClassifier):
    def forward(self, query_images: Tensor) -> Tensor:
        features = self.compute_features(query_images)
        distances = self.l2_distance_to_prototypes(features)
        logits = -distances
        return self.softmax_if_specified(logits)
    
    @staticmethod
    def is_transductive() -> bool:
        return False
    
    def compute_prototypes_and_store_support_set(self, support_images: Tensor, support_labels: Tensor):
        self.support_features = self.compute_features(support_images)
        self.support_labels = support_labels
        self.prototypes = compute_prototypes(self.support_features, support_labels)

# Setup initialization arguments
backbone = SimpleBackbone(input_dim=5, output_dim=4)
feature_center = torch.randn(4)

INIT_ARGS = {
    'backbone': backbone,
    'use_softmax': True,
    'feature_centering': feature_center,
    'feature_normalization': 2.0
}

# Setup computation arguments for compute_features method
ARGS = {
    'images': torch.randn(2, 5)
}

METHOD = 'compute_features'

# Construct and call
classifier = ConcreteClassifier(**INIT_ARGS)
result = getattr(classifier, METHOD)(**ARGS)
print(f"Result shape: {result.shape}")
print(f"Result: {result}")
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 Tensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
GatherLayer Ran
ran on a synthesized input · constructed an object; no result was computed
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("3144f593c6905e78")
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, GatherLayer: 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 tensorflow as tf
import numpy as np

# Create a small input tensor for testing
# Shape: (batch_size=2, features=4)
input_tensor = tf.constant([[1.0, 2.0, 3.0, 4.0],
                            [5.0, 6.0, 7.0, 8.0]])

# Define indices to gather along the specified axis
# These indices will select specific elements
indices = tf.constant([0, 2])

# Define the axis along which to gather
axis = 1

# Construct the ARGS dictionary with all parameters for GatherLayer
ARGS = {
    'indices': indices,
    'axis': axis,
    'name': 'test_gather_layer'
}
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 GatherLayer — 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 GatherLayer 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
Net Ran
ran on a synthesized input
Hsankesara/DeepResearch/Prototypical_Nets/prototypicalNet.py
code served (permissive licence) · get_code("fdc838c064947cc9")
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 Tensor, ndim 2, 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

# The __init__ method takes no parameters beyond self
INIT_ARGS = {}

# The forward method takes x as input
# According to the docstring, the network expects images of dimension (28x28x3)
# We'll create a batch of 2 images with shape (batch_size, channels, height, width)
ARGS = {
    'x': torch.randn(2, 3, 28, 28)
}
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 Tensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
PSCBert Ran
ran on a synthesized input · constructed an object; no result was computed
amazon-research/dse/pretrain/models/Transformers.py
code served (permissive licence) · get_code("c9d933d5fb7c5095")
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, PSCBert: 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 torch
import torch.nn as nn
from transformers import BertConfig

torch.manual_seed(0)

# Create a minimal BertConfig
bert_config = BertConfig(
    vocab_size=100,
    hidden_size=64,
    num_hidden_layers=2,
    num_attention_heads=2,
    intermediate_size=128,
    hidden_dropout_prob=0.1,
    attention_probs_dropout_prob=0.1,
)

# Define ARGS dictionary with all parameters for PSCBert.__init__
ARGS = {
    'config': bert_config,
    'num_classes': 2,
    'feat_dim': 32,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PSCBert — 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 PSCBert 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
ProtoNet Ran
ran on a synthesized input · constructed an object; no result was computed
Sha-Lab/FEAT/model/models/protonet.py
code served (permissive licence) · get_code("4eb979c22e4e42d0")
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, ProtoNet: 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 torch
import numpy as np
import torch.nn as nn

torch.manual_seed(0)

class MockConvNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = nn.Conv2d(3, 64, kernel_size=3, padding=1)
    
    def forward(self, x):
        # Return embeddings of shape (batch, emb_dim)
        batch_size = x.shape[0]
        return torch.randn(batch_size, 64)

class MockArgs:
    def __init__(self):
        self.backbone_class = 'ConvNet'
        self.way = 5
        self.shot = 1
        self.query = 2
        self.eval_way = 5
        self.eval_shot = 1
        self.eval_query = 2
        self.temperature = 1.0

# Monkey patch to avoid importing non-existent model files
import sys
from unittest.mock import MagicMock

sys.modules['model'] = MagicMock()
sys.modules['model.networks'] = MagicMock()
sys.modules['model.networks.convnet'] = MagicMock()
sys.modules['model.networks.res12'] = MagicMock()
sys.modules['model.networks.res18'] = MagicMock()
sys.modules['model.networks.WRN28'] = MagicMock()

# Create mock encoder
mock_encoder = MockConvNet()

# Patch the ConvNet import
import model.networks.convnet as convnet_module
convnet_module.ConvNet = MockConvNet

args = MockArgs()

ARGS = {
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
model, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ProtoNet — 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 ProtoNet 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
ProtoNet Ran
ran on a synthesized input · constructed an object; no result was computed
orobix/Prototypical-Networks-for-Few-shot-Learning-PyTorch/src/protonet.py
code served (permissive licence) · get_code("0b1720468e69b9da")
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, ProtoNet: 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 torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "x_dim": 1,
    "hid_dim": 64,
    "z_dim": 64,
}
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 ProtoNet — 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 ProtoNet 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
ProtoNet Ran
ran on a synthesized input
lif31up/prototypical-network/model/ProtoNet.py
code served (permissive licence) · get_code("516db6627dd0d56e")
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 Tensor, ndim 2, 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
from torch import nn
import torchvision as tv

# Stand-in for Config
class MockConfig:
    def __init__(self):
        self.input_channels = 1
        self.hidden_channels = 4
        self.output_channels = 1
        self.n_convs = 2
        self.kernel_size = 3
        self.padding = 1
        self.stride = 1
        self.bias = True
        self.iterations = 2
        self.alpha = 0.0001
        self.eps = 1e-05
        self.epochs = 1
        self.batch_size = 2
        self.n_way = 3
        self.k_shot = 2
        self.n_query = 2
        self.save_to = None
        self.transform = tv.transforms.Compose([
            tv.transforms.Resize((28, 28)),
            tv.transforms.Grayscale(num_output_channels=1),
            tv.transforms.ToTensor(),
            tv.transforms.Normalize(mean=[0.5], std=[0.5])
        ])
        self.dummy = torch.zeros(1, self.input_channels, 8, 8)
        self.clip_grad = True

def mock_get_imageset():
    # Return a mock dataset with tiny dummy data
    class MockDataset:
        def __init__(self):
            self.data = torch.randn(6, 1, 8, 8)  # 6 samples, 1 channel, 8x8
            self.targets = torch.tensor([0, 0, 1, 1, 2, 2])  # 3 classes, 2 samples each
        def __len__(self):
            return len(self.data)
        def __getitem__(self, idx):
            return self.data[idx], self.targets[idx]
    return MockDataset()

# Override config's imageset and transform
config = MockConfig()
config.imageset = mock_get_imageset()

# INIT_ARGS for ProtoNet
INIT_ARGS = {
    'config': config
}

# ARGS for forward pass
# Create dummy input tensors matching the expected shapes
batch_size = config.batch_size
n_way = config.n_way
k_shot = config.k_shot
n_query = config.n_query
input_channels = config.input_channels
height, width = 8, 8  # Small spatial dims

# Input tensor: (batch_size, input_channels, height, width)
x = torch.randn(batch_size, input_channels, height, width)

# Prototypes tensor: (n_way, output_features)
# output_features = output_channels * height * width (after flattening)
output_features = config.output_channels * height * width
prototypes = torch.randn(n_way, output_features)

ARGS = {
    'x': x,
    'prototypes': prototypes
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
ProtoNet Ran
ran on a synthesized input · constructed an object; no result was computed
RongKaiWeskerMA/INSTA/model/models/protonet.py
code served (permissive licence) · get_code("c7a6d6154fec9ddf")
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, ProtoNet: 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 torch
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create a minimal stand-in ResNet encoder
class MinimalResNet(nn.Module):
    def __init__(self, output_dim=640):
        super().__init__()
        self.output_dim = output_dim
        self.fc = nn.Linear(3, output_dim)
    
    def forward(self, x):
        # x shape: (batch, 3, H, W) or flattened
        # We'll just flatten and project to output_dim
        batch_size = x.size(0)
        return self.fc(torch.randn(batch_size, 3))

# Create a minimal args class
class Args:
    def __init__(self):
        self.backbone_class = 'Res12'
        self.way = 5
        self.shot = 1
        self.query = 2
        self.eval_way = 5
        self.eval_shot = 1
        self.eval_query = 2
        self.grad_cam = False
        self.temperature = 1.0

# Monkey patch the imports to avoid missing model.networks modules
import sys
from types import ModuleType

# Create mock modules
res12_module = ModuleType('res12')
res18_module = ModuleType('res18')

class MockResNet(nn.Module):
    def __init__(self, output_dim=640):
        super().__init__()
        self.output_dim = output_dim
        self.fc = nn.Linear(3, output_dim)
    
    def forward(self, x):
        batch_size = x.size(0)
        return self.fc(torch.randn(batch_size, 3))

res12_module.ResNet = lambda: MockResNet(640)
res18_module.ResNet = lambda: MockResNet(512)

# Create the model.networks module structure
model_module = ModuleType('model')
networks_module = ModuleType('networks')
networks_module.res12 = res12_module
networks_module.res18 = res18_module
model_module.networks = networks_module

sys.modules['model'] = model_module
sys.modules['model.networks'] = networks_module
sys.modules['model.networks.res12'] = res12_module
sys.modules['model.networks.res18'] = res18_module

args = Args()

ARGS = {
    'args': args
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
model, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ProtoNet — 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 ProtoNet 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
ProtoNet Ran
ran on a synthesized input · constructed an object; no result was computed
COAOX/Cifar-Prototypical/src/protonet.py
code served (permissive licence) · get_code("1bf49c188356596e")
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, ProtoNet: 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 torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    "x_dim": 3,
    "hid_dim": 64,
    "z_dim": 64,
}
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 ProtoNet — 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 ProtoNet 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
ProtoNetHead Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
andrewbo29/mtm-meta-learning-sa/protonet/models/classification_heads.py
code served (permissive licence) · get_code("75cb52150d9a660a")
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, 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.functional as F

torch.manual_seed(0)

# Set up parameters for ProtoNetHead
tasks_per_batch = 2
n_way = 3
n_shot = 2
n_support = n_way * n_shot  # 6
n_query = 4
d = 5  # embedding dimension

device = torch.device('cpu')

# Create query tensor: (tasks_per_batch, n_query, d)
query = torch.randn(tasks_per_batch, n_query, d)

# Create support tensor: (tasks_per_batch, n_support, d)
support = torch.randn(tasks_per_batch, n_support, d)

# Create support_labels tensor: (tasks_per_batch, n_support)
# Labels should be in range [0, n_way)
support_labels = torch.tensor([
    [0, 0, 1, 1, 2, 2],  # task 1: 2 examples per class
    [0, 0, 1, 1, 2, 2]   # task 2: 2 examples per class
])

ARGS = {
    'query': query,
    'support': support,
    'support_labels': support_labels,
    'n_way': n_way,
    'n_shot': n_shot,
    'device': device,
    'normalize': True
}
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, 3) — shape (2, 4, 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
ProtoNetHead Ran
ran; our contract draft was wrong, not the code
goldblum/AdversarialQuerying/models/classification_heads.py
code served (permissive licence) · get_code("58af5957818ea856")
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; no output shape is stated. 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 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

torch.manual_seed(0)

# Parameters for ProtoNetHead
tasks_per_batch = 2
n_way = 3
n_shot = 2
n_support = n_way * n_shot  # 6
n_query = 4
d = 5  # embedding dimension

# Create tensors
query = torch.randn(tasks_per_batch, n_query, d)
support = torch.randn(tasks_per_batch, n_support, d)
support_labels = torch.tensor([[0, 0, 1, 1, 2, 2], [0, 0, 1, 1, 2, 2]])

ARGS = {
    "query": query,
    "support": support,
    "support_labels": support_labels,
    "n_way": n_way,
    "n_shot": n_shot,
    "normalize": True
}
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 — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
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
Protonet Ran
ran on a synthesized input · constructed an object; no result was computed
jakesnell/prototypical-networks/protonets/models/few_shot.py
code served (permissive licence) · get_code("a40352cfd6475ec3")
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, Protonet: 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
import torch.nn as nn

torch.manual_seed(0)

class SimpleEncoder(nn.Module):
    def __init__(self):
        super(SimpleEncoder, self).__init__()
        self.conv = nn.Conv2d(3, 16, kernel_size=3, padding=1)
        self.fc = nn.Linear(16 * 4 * 4, 8)
    
    def forward(self, x):
        batch_size = x.size(0)
        x = self.conv(x)
        x = x.view(batch_size, -1)
        x = self.fc(x)
        return x

encoder = SimpleEncoder()

n_class = 2
n_support = 3
n_query = 2
img_height = 4
img_width = 4
img_channels = 3

xs = torch.randn(n_class, n_support, img_channels, img_height, img_width)
xq = torch.randn(n_class, n_query, img_channels, img_height, img_width)

sample = {
    'xs': xs,
    'xq': xq
}

ARGS = {
    'encoder': encoder
}
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 Protonet — 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 Protonet 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
PrototypeLoss Ran
ran on a synthesized input
maxstrobel/HCN-PrototypeLoss-PyTorch/processor/processor_protonet.py
code served (permissive licence) · get_code("17f40aa50a000486")
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
import torch.nn as nn
import torch.nn.functional as F

def euclidean_dist(x, y):
    """
    Compute pairwise euclidean distance
    :param x: batch of data
    :param y: batch of data
    :return: pairwise euclidean distances
    """
    n = x.size(0)
    m = y.size(0)
    d = x.size(1)
    assert d == y.size(1)
    x = x.unsqueeze(1).expand(n, m, d)
    y = y.unsqueeze(0).expand(n, m, d)
    return torch.pow(x - y, 2).sum(2)

class PrototypeLoss(nn.Module):

    def forward(self, z_query, z_support, n_class, n_support, n_query):
        """
        Calculate prototype loss
        :param z_query: Query points
        :param z_support: Support points
        :param n_class: Number of classes
        :param n_support: Number of support points
        :param n_query: Number of query points
        :return: prototype loss
        """
        device = z_query.device
        z_proto = z_support.view(n_class, n_support, -1).mean(dim=1)
        distances = euclidean_dist(z_query, z_proto)
        target = torch.arange(n_class).view(n_class, 1, 1).expand(n_class, n_query, 1)
        target = target.long().to(device)
        log_p_y = F.log_softmax(-distances, dim=1).view(n_class, n_query, n_class)
        loss = -log_p_y.gather(2, target).mean()
        return (loss, distances)


INIT_ARGS = {}

n_class = 2
n_support = 3
n_query = 4
feature_dim = 5

z_support = torch.randn(n_class * n_support, feature_dim)
z_query = torch.randn(n_class * n_query, feature_dim)

ARGS = {
    'z_query': z_query,
    'z_support': z_support,
    'n_class': n_class,
    'n_support': n_support,
    'n_query': n_query,
}

if __name__ == '__main__':
    model = PrototypeLoss(**INIT_ARGS)
    loss, distances = model(**ARGS)
    print(f"Loss: {loss}")
    print(f"Distances shape: {distances.shape}")
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)
Prototypical Ran
ran on a synthesized input · constructed an object; no result was computed
ulises-jeremias/prototypical-networks-tf/protonet/models/prototypical.py
code served (permissive licence) · get_code("08f5684e7687d43e")
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, Prototypical: 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 tensorflow as tf
import numpy as np

# Create a minimal base_model if needed
# The base_model is optional (can be None), but we'll create a simple one
class SimpleBaseModel(tf.keras.Model):
    def __init__(self):
        super(SimpleBaseModel, self).__init__()
        self.dense = tf.keras.layers.Dense(64)
    
    def call(self, x):
        return self.dense(x)

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

# Define arguments for Prototypical
ARGS = {
    'n_support': 2,
    'n_query': 3,
    'w': 4,
    'h': 5,
    'c': 3,
    'nb_layers': 2,
    'nb_filters': 8,
    'base_model': None
}
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 Prototypical — 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 Prototypical 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
Prototypical Ran
ran on a synthesized input · constructed an object; no result was computed
schatty/prototypical-networks-tf/prototf/models/prototypical.py
code served (permissive licence) · get_code("180e010d21e18799")
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, Prototypical: 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)

# Create valid arguments for Prototypical class
ARGS = {
    "n_support": 5,
    "n_query": 3,
    "w": 28,
    "h": 28,
    "c": 3,
}

# Verify the setup by instantiating the model
model = tf.keras.Model(**ARGS) if False else None  # Just for type checking

# Create small test tensors for the call method
n_class = 2
n_support = 5
n_query = 3
w, h, c = 28, 28, 3

# Create support and query tensors with correct shapes
support = tf.random.normal([n_class, n_support, w, h, c])
query = tf.random.normal([n_class, n_query, w, h, c])
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 Prototypical — 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 Prototypical 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
PrototypicalClassifier Ran
ran on a synthesized input · constructed an object; no result was computed
learnables/learn2learn/learn2learn/nn/protonet.py
code served (permissive licence) · get_code("46fbc98d3054326d")
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, PrototypicalClassifier: 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 torch

torch.manual_seed(0)

# Create small support embeddings: (6, 4) means 6 samples with 4-dim embeddings
support = torch.randn(6, 4)

# Create labels: 3 samples of class 0, 3 samples of class 1
labels = torch.tensor([0, 0, 0, 1, 1, 1])

ARGS = {
    'support': support,
    'labels': labels,
    'distance': 'euclidean',
    'normalize': 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 PrototypicalClassifier — 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 PrototypicalClassifier 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
PrototypicalNetwork Ran
ran on a synthesized input
fabian57fabian/prototypical-networks-few-shot-learning/src/prototypical_net.py
pointer only (licence: GPL-3.0) · get_code("aa420da10668ccd5")
How it ran

The body of this sample is withheld: GPL-3.0, as GitHub detects it on this paper's repository, fabian57fabian/prototypical-networks-few-shot-learning, is not in the permissive set Syntology serves inline. 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.

PrototypicalNetwork Ran
ran on a synthesized input
mariehane/prototypical-networks/prototypical.py
pointer only (licence: NONE) · get_code("f5933c3730b6f339")
How it ran

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

PrototypicalNetworks Ran
ran on a synthesized input
sicara/easy-few-shot-learning/easyfsl/methods/prototypical_networks.py
code served (permissive licence) · get_code("341b0d9276c53ee2")
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 Tensor, ndim 2, 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
from torch import nn, Tensor

class FewShotClassifier(nn.Module):
    """
    Abstract class providing methods usable by all few-shot classification algorithms
    """

    def __init__(self, backbone: nn.Module=None, use_softmax: bool=False, feature_centering: Tensor=None, feature_normalization: float=None):
        """
        Initialize the Few-Shot Classifier
        Args:
            backbone: the feature extractor used by the method. Must output a tensor of the
                appropriate shape (depending on the method).
                If None is passed, the backbone will be initialized as nn.Identity().
            use_softmax: whether to return predictions as soft probabilities
            feature_centering: a features vector on which to center all computed features.
                If None is passed, no centering is performed.
            feature_normalization: a value by which to normalize all computed features after centering.
                It is used as the p argument in torch.nn.functional.normalize().
                If None is passed, no normalization is performed.
        """
        super().__init__()
        self.backbone = backbone if backbone is not None else nn.Identity()
        self.use_softmax = use_softmax
        self.prototypes = torch.tensor(())
        self.support_features = torch.tensor(())
        self.support_labels = torch.tensor(())
        self.feature_centering = feature_centering if feature_centering is not None else torch.tensor(0)
        self.feature_normalization = feature_normalization

    def forward(self, query_images: Tensor) -> Tensor:
        """
        Predict classification labels.
        Args:
            query_images: images of the query set of shape (n_query, **image_shape)
        Returns:
            a prediction of classification scores for query images of shape (n_query, n_classes)
        """
        raise NotImplementedError('All few-shot algorithms must implement a forward method.')

    def process_support_set(self, support_images: Tensor, support_labels: Tensor):
        """
        Harness information from the support set, so that query labels can later be predicted using a forward call.
        The default behaviour shared by most few-shot classifiers is to compute prototypes and store the support set.
        Args:
            support_images: images of the support set of shape (n_support, **image_shape)
            support_labels: labels of support set images of shape (n_support, )
        """
        pass

    @staticmethod
    def is_transductive() -> bool:
        raise NotImplementedError('All few-shot algorithms must implement a is_transductive method.')

    def compute_features(self, images: Tensor) -> Tensor:
        """
        Compute features from images and perform centering and normalization.
        Args:
            images: images of shape (n_images, **image_shape)
        Returns:
            features of shape (n_images, feature_dimension)
        """
        original_features = self.backbone(images)
        centered_features = original_features - self.feature_centering
        if self.feature_normalization is not None:
            return nn.functional.normalize(centered_features, p=self.feature_normalization, dim=1)
        return centered_features

    def softmax_if_specified(self, output: Tensor, temperature: float=1.0) -> Tensor:
        """
        If the option is chosen when the classifier is initialized, we perform a softmax on the
        output in order to return soft probabilities.
        Args:
            output: output of the forward method of shape (n_query, n_classes)
            temperature: temperature of the softmax
        Returns:
            output as it was, or output as soft probabilities, of shape (n_query, n_classes)
        """
        return (temperature * output).softmax(-1) if self.use_softmax else output

    def l2_distance_to_prototypes(self, samples: Tensor) -> Tensor:
        """
        Compute prediction logits from their euclidean distance to support set prototypes.
        Args:
            samples: features of the items to classify of shape (n_samples, feature_dimension)
        Returns:
            prediction logits of shape (n_samples, n_classes)
        """
        return -torch.cdist(samples, self.prototypes)

    def cosine_distance_to_prototypes(self, samples: Tensor) -> Tensor:
        """
        Compute prediction logits from their cosine distance to support set prototypes.
        Args:
            samples: features of the items to classify of shape (n_samples, feature_dimension)
        Returns:
            prediction logits of shape (n_samples, n_classes)
        """
        return nn.functional.normalize(samples, dim=1) @ nn.functional.normalize(self.prototypes, dim=1).t()


backbone = nn.Sequential(
    nn.Linear(5, 4),
    nn.ReLU(),
    nn.Linear(4, 4)
)

INIT_ARGS = {
    'backbone': backbone,
    'use_softmax': False,
    'feature_centering': torch.zeros(4),
    'feature_normalization': 2.0
}

ARGS = {
    'images': torch.randn(2, 5)
}

METHOD = 'compute_features'

if __name__ == '__main__':
    classifier = FewShotClassifier(**INIT_ARGS)
    result = getattr(classifier, METHOD)(**ARGS)
    print(f"Result shape: {result.shape}")
    print(f"Result: {result}")
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 Tensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
R2D2Head Ran
ran on a synthesized input
ajfisch/few-shot-cp/chembl/modeling/encoders.py
pointer only (licence: NONE) · get_code("9c75d36a2cd52c03")
How it ran

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

backbone_protonet Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("f5c1a7acdfadd94b")
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 EagerTensor, ndim 4, dtype family float, shape (2, 0, 0, 64) 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 tensorflow as tf
import numpy as np

# Create a small input tensor
# Shape: [batch_size, height, width, channels]
# Using batch_size=2, height=4, width=3, channels=1
batch_size = 2
height = 4
width = 3
channels = 1

inputs = tf.random.normal((batch_size, height, width, channels))

# Define ARGS dict with all parameters for backbone_protonet
ARGS = {
    'x': inputs,
    'filters': 64,
    'train_bn': False
}
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 EagerTensor, ndim 4, dtype family float, shape (2, 0, 0, 64) — shape (2, 0, 0, 64) 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
calc_euclidian_dists Ran
ran, honoured the contract we drafted
ulises-jeremias/prototypical-networks-tf/protonet/models/prototypical.py
code served (permissive licence) · get_code("a84bbc21fe9abc8d")
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 EagerTensor, 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 tensorflow as tf

# Create two small 3D tensors for testing
# x: shape (2, 4) - batch of 2, feature dimension 4
# y: shape (3, 4) - batch of 3, feature dimension 4
x = tf.constant([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0]
], dtype=tf.float32)

y = tf.constant([
    [1.5, 2.5, 3.5, 4.5],
    [5.5, 6.5, 7.5, 8.5],
    [9.0, 10.0, 11.0, 12.0]
], dtype=tf.float32)

ARGS = {
    "x": x,
    "y": y
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, 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
computeGramMatrix Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
andrewbo29/mtm-meta-learning-sa/protonet/models/classification_heads.py
code served (permissive licence) · get_code("6134727f9d286287")
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, 3, 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 small tensors with distinct dimensions
# A: (n_batch=2, n=3, d=4)
# B: (n_batch=2, m=5, d=4)
A = torch.randn(2, 3, 4)
B = torch.randn(2, 5, 4)

ARGS = {
    "A": A,
    "B": B,
}
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, 3, 5) — shape (2, 3, 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
compute_prototypes Ran
ran; our contract draft was wrong, not the code
akshatgarg99/FewShotLearning/Utils/protonet_calculations.py
pointer only (licence: NONE) · get_code("4de656fa284263c4")
How it ran

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

compute_prototypes Ran
ran, honoured the contract we drafted
learnables/learn2learn/learn2learn/nn/protonet.py
code served (permissive licence) · get_code("b737a25e6c29ebc7")
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 (3, 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)

# support: tensor of shape (num_samples, *feature_dims)
# For a few-shot learning scenario, we'll create embeddings
support = torch.randn(6, 4)  # 6 samples, 4-dimensional embeddings

# labels: tensor of class labels, one per sample
# We'll have 3 samples of class 0, 2 of class 1, 1 of class 2
labels = torch.tensor([0, 0, 0, 1, 1, 2])

ARGS = {
    "support": support,
    "labels": labels,
}
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 (3, 4) — shape (3, 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
compute_prototypes Ran
ran; our contract draft was wrong, not the code
oscarknagg/few-shot/few_shot/proto.py
code served (permissive licence) · get_code("c442feb515d4d8f3")
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)

# Parameters for compute_prototypes
# k=2 (2-way classification), n=3 (3-shot), d=4 (embedding dimension)
# support shape should be (n*k, d) = (6, 4)

k = 2
n = 3
support = torch.randn(n * k, 4)

ARGS = {
    "support": support,
    "k": k,
    "n": n,
}
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
compute_prototypes Ran
ran; our contract draft was wrong, not the code
sicara/easy-few-shot-learning/easyfsl/methods/prototypical_networks.py
code served (permissive licence) · get_code("9b846f6eab1ad481")
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 (3, 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 support features: shape (6, 4) - 6 instances, 4-dimensional features
support_features = torch.randn(6, 4)

# Create support labels: shape (6,) - 6 instances with 3 classes (0, 1, 2)
support_labels = torch.tensor([0, 0, 1, 1, 2, 2])

ARGS = {
    "support_features": support_features,
    "support_labels": support_labels,
}
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 (3, 4) — shape (3, 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
conv_block Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from few-shot-learning-on-chest-x-ray/fsl_subspace
pointer only; the stored copy get_code serves, from few-shot-learning-on-chest-x-ray/fsl_subspace, is pointer only (licence: NONE) · get_code("4018d80d0425da98")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

conv_block Ran
ran; our contract draft was wrong, not the code
jsalbert/prototypical-networks/models/convnet_mini.py
pointer only (licence: MIT); the stored copy get_code serves, from tiangeluo/fsl-global, is pointer only (licence: GPL-2.0) · get_code("9d556d61294bb0a8")
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 tiangeluo/fsl-global, and GPL-2.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

conv_block Ran
ran; our contract draft was wrong, not the code
cyvius96/prototypical-network-pytorch/convnet.py
code served (permissive licence) · get_code("b0a1286b15398404")
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)

ARGS = {
    "in_channels": 3,
    "out_channels": 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 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
conv_block Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("bf404583e5ea3465")
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 EagerTensor, ndim 4, dtype family float, shape (2, 2, 1, 16) 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 tensorflow as tf
import numpy as np

# Create a small input tensor: [batch_size=2, height=4, width=3, channels=2]
inputs = tf.constant(np.random.randn(2, 4, 3, 2).astype(np.float32))

# Define arguments
ARGS = {
    'inputs': inputs,
    'filters': 16,
    'block': 'test_block_1',
    'train_bn': False
}
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 EagerTensor, ndim 4, dtype family float, shape (2, 2, 1, 16) — shape (2, 2, 1, 16) 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
conv_block Ran
ran; our contract draft was wrong, not the code
joshfp/one-shot-learning/model.py
pointer only (licence: NONE) · get_code("57d2c3e6cce78748")
How it ran

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

euclidean_dist Ran
ran; our contract draft was wrong, not the code
this paper's copy was not recorded; identical code first harvested from linusericsson/ssl-transfer
pointer only · get_code("4dd319c45d372246")
How it ran

The body of this sample is withheld: this paper's copy of the code was not recorded (its link names no repository or source path), so no licence was read for it. 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.

euclidean_dist Ran
ran; our contract draft was wrong, not the code
joshfp/one-shot-learning/model.py
pointer only (licence: NONE) · get_code("0d9f00b53a9558f8")
How it ran

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

euclidean_dist Ran
ran; our contract draft was wrong, not the code
maxstrobel/HCN-PrototypeLoss-PyTorch/processor/processor_protonet.py
code served (permissive licence) · get_code("7ad5cda37c731a0a")
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, 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

torch.manual_seed(0)

# Create two small tensors with distinct dimensions
# x: batch size 2, feature dimension 4
# y: batch size 3, feature dimension 4
x = torch.randn(2, 4)
y = torch.randn(3, 4)

ARGS = {
    "x": x,
    "y": y,
}
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, 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
euclidean_dist Ran
ran on a synthesized input
jsalbert/prototypical-networks/utils.py
code served (permissive licence) · get_code("e439ae68f44dd2f2")
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)

# Create two small tensors with distinct shapes for a and b
# a: shape (2, 4) - 2 samples, 4 dimensions
# b: shape (3, 4) - 3 samples, 4 dimensions
a = torch.randn(2, 4)
b = torch.randn(3, 4)

ARGS = {
    'a': a,
    'b': b
}
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
few_shot_euclidean_similarity Ran
ran, honoured the contract we drafted
zz990704/Reimplementation-Prototypical-network/protonet.py
pointer only (licence: NONE) · get_code("24477e2d27f5e8f7")
How it ran

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

identity_block Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("f83f4ae2b6c3bc8d")
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 EagerTensor, ndim 4, dtype family float, shape (2, 4, 3, 64) 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 tensorflow as tf
import numpy as np

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

# Create a small input tensor: [batch_size=2, height=4, width=3, channels=64]
input_tensor = tf.random.normal(shape=(2, 4, 3, 64), dtype=tf.float32)

# Define filters list: [num_filters_1, num_filters_2, num_filters_3]
# num_filters_3 should equal input_tensor's channels (64) for identity shortcut
filters = [32, 32, 64]

# stage should be in [2, 5]
stage = 2

# block should be a lowercase letter
block = 'a'

# train_bn controls batch normalization behavior
train_bn = False

ARGS = {
    'input_tensor': input_tensor,
    'filters': filters,
    'stage': stage,
    'block': block,
    'train_bn': train_bn
}
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 EagerTensor, ndim 4, dtype family float, shape (2, 4, 3, 64) — shape (2, 4, 3, 64) 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
pairwise_distances Ran
ran, honoured the contract we drafted
akshatgarg99/FewShotLearning/Utils/protonet_calculations.py
pointer only (licence: NONE) · get_code("276c42468f5e8af0")
How it ran

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

pairwise_distances Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
oscarknagg/few-shot/few_shot/proto.py
code served (permissive licence) · get_code("264452c073b536a8")
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

torch.manual_seed(0)

# Create query samples: shape (n_x, d) where n_x=2, d=4
x = torch.randn(2, 4)

# Create class prototypes: shape (n_y, d) where n_y=3, d=4
y = torch.randn(3, 4)

# Matching function - one of 'l2', 'cosine', or 'dot'
matching_fn = 'l2'

ARGS = {
    'x': x,
    'y': y,
    'matching_fn': matching_fn
}
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
pairwise_distances Ran
ran; our contract draft was wrong, not the code
KamalM8/Few-Shot-learning-Fashion/few_shot/proto.py
code served (permissive licence) · get_code("9c31448b2eee894f")
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)

# Create small tensors with distinct dimensions
# x: query samples (n_x=2, d=4)
# y: class prototypes (n_y=3, d=4)
x = torch.randn(2, 4)
y = torch.randn(3, 4)

# Create a minimal model with a scale attribute
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.scale = 2.0
    
model = MinimalModel()

# Test all three matching functions
matching_fn = 'l2'

ARGS = {
    'x': x,
    'y': y,
    'matching_fn': matching_fn,
    'model': model
}
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
proto_dist Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
barnrang/Prototypical-network-keras-reimplementation/util/loss.py
pointer only (licence: NONE) · get_code("6ef2681ed9527bea")
How it ran

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

proto_net_episode Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
akshatgarg99/FewShotLearning/Utils/protonet_calculations.py
pointer only (licence: NONE) · get_code("d76a7926a5b4328a")
How it ran

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

proto_net_episode Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
oscarknagg/few-shot/few_shot/proto.py
code served (permissive licence) · get_code("228cdfe23ddb6e6a")
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
from torch.optim import SGD
from torch.nn import CrossEntropyLoss

torch.manual_seed(0)

# Create a simple embedding model
class SimpleEmbeddingModel(nn.Module):
    def __init__(self, input_dim=5, embedding_dim=4):
        super().__init__()
        self.fc = nn.Linear(input_dim, embedding_dim)
    
    def forward(self, x):
        return self.fc(x)

# Instantiate the model
model = SimpleEmbeddingModel(input_dim=5, embedding_dim=4)

# Create optimizer
optimiser = SGD(model.parameters(), lr=0.01)

# Create loss function
loss_fn = CrossEntropyLoss()

# Parameters for the few-shot task
n_shot = 2
k_way = 3
q_queries = 2

# Total samples: support set (n_shot * k_way) + query set (q_queries * k_way)
support_samples = n_shot * k_way  # 6
query_samples = q_queries * k_way  # 6
total_samples = support_samples + query_samples  # 12

# Create input tensor x: (total_samples, input_dim)
x = torch.randn(total_samples, 5)

# Create labels y for query set only: (query_samples,)
# Labels should be class indices from 0 to k_way-1
y = torch.tensor([0, 0, 1, 1, 2, 2])

ARGS = {
    'model': model,
    'optimiser': optimiser,
    'loss_fn': loss_fn,
    'x': x,
    'y': y,
    'n_shot': n_shot,
    'k_way': k_way,
    'q_queries': q_queries,
    'distance': 'l2',
    'train': True
}
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
tf_acc Ran
ran, honoured the contract we drafted
minseop-aitrics/FewshotLearning/ProtoNet/lib/networks.py
pointer only (licence: NONE) · get_code("d76ff0bd573853cd")
How it ran

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

Config Not yet run
unverified (harvested, no recorded run)
lif31up/prototypical-network/model/ProtoNet.py
code served (permissive licence) · get_code("be2b72d9c5987b86")
How it ran

no invocation recorded.

FewShotModel Not yet run
unverified (harvested, no recorded run)
Sha-Lab/FEAT/model/models/protonet.py
code served (permissive licence) · get_code("6137fa2b68c126ad")
How it ran

no invocation recorded.

FewShotModel_1 Not yet run
unverified (harvested, no recorded run)
RongKaiWeskerMA/INSTA/model/models/protonet.py
code served (permissive licence) · get_code("e7053ecec6d213c4")
How it ran

no invocation recorded.

Network Not yet run
unverified (harvested, no recorded run)
minseop-aitrics/FewshotLearning/ProtoNet/lib/networks.py
pointer only (licence: NONE) · get_code("7031de287b846201")
How it ran

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

ProtoNet Not yet run
unverified (harvested, no recorded run)
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("4c32fdbf4bc74c91")
How it ran

no invocation recorded.

ProtoNet Not yet run
unverified (harvested, no recorded run)
minseop-aitrics/FewshotLearning/ProtoNet/lib/networks.py
pointer only (licence: NONE) · get_code("ff981c1b19834fdd")
How it ran

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

PrototypicalNet Not yet run
unverified (harvested, no recorded run)
Hsankesara/DeepResearch/Prototypical_Nets/prototypicalNet.py
code served (permissive licence) · get_code("dab17e19991f263e")
How it ran

no invocation recorded.

PrototypicalNetwork Not yet run
unverified (harvested, no recorded run)
joshfp/one-shot-learning/model.py
pointer only (licence: NONE) · get_code("9bd97fbc6d63a34b")
How it ran

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

accuracy_top_k Not yet run
unverified (harvested, no recorded run)
jsalbert/prototypical-networks/utils.py
code served (permissive licence) · get_code("f006ac7d22562283")
How it ran

no invocation recorded.

backbone_resnet Not yet run
unverified (harvested, no recorded run)
DrMMZ/ProtoNet/model/ProtoNet.py
code served (permissive licence) · get_code("d93d7b512badec9b")
How it ran

no invocation recorded.

Showing the first 60. An agent gets every one from get_harvested_code_for_paper("1703.05175").

Also present in other papers' code

Of 64 samples lifted from this paper's linked repositories, 64 carry a function identity and 0 do not. Of the 62 distinct functions with an identity, 8 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 2 the same month, 6 later) and 54 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
euclidean_dist
brick of this paper's assembly: helper, metric
16 other papers
16 later · 2 only as an assembly brick
1902.08605 (2019-02)
Are Few-Shot Learning Benchmarks too Simple ? Solving them without Task Supervision at Test-Time
1905.13613 (2019-05)
Regression Networks for Meta-Learning Few-Shot Classification
1912.07200 (2019-12)
A Broader Study of Cross-Domain Few-Shot Learning
and 13 more not named here
conv_block
brick of this paper's assembly: model
11 other papers
11 later
1908.05257 (2019-08)
Few-Shot Learning with Global Class Representations
1911.06045 (2019-11)
Self-Supervised Learning For Few-Shot Image Classification
2020.emnlp-demos.29 (2020 (year only))
IsOBS: An Information System for Oracle Bone Script
and 8 more not named here
computeGramMatrix
brick of this paper's assembly: helper
8 other papers
8 later · 1 only as an assembly brick
ijcai2020_0377 (2020 (year only))
Consistent MetaReg: Alleviating Intra-task Discrepancy for Better Meta-knowledge
2010.00763 (2020-10)
BONGARD-LOGO: A New Benchmark for Human-Level Concept Learning and Reasoning
2010.07092 (2020-10)
Data Augmentation for Meta-Learning
and 5 more not named here
FewShotClassifier
brick of this paper's assembly: model
2 other papers
2 later
2006.15486 (2020-06)
Laplacian Regularized Few-Shot Learning
2008.11297 (2020-08)
Transductive Information Maximization For Few-Shot Learning
compute_prototypes
brick of this paper's assembly: helper
2 other papers
2 later
2006.15486 (2020-06)
Laplacian Regularized Few-Shot Learning
2008.11297 (2020-08)
Transductive Information Maximization For Few-Shot Learning
Network
brick of this paper's assembly: helper
1 other paper
1 the same month · 1 only as an assembly brick
1703.03400 (2017-03)
Model-Agnostic Meta-Learning for Fast Adaptation of Deep Networks
ProtoNetHead
brick of this paper's assembly: entry
1 other paper
1 later · 1 only as an assembly brick
2106.12900 (2021-06)
Long-term Cross Adversarial Training: A Robust Meta-learning Method for Few-shot Classification Tasks
tf_acc
brick of this paper's assembly: metric
1 other paper
1 the same month · 1 only as an assembly brick
1703.03400 (2017-03)
Model-Agnostic Meta-Learning for Fast Adaptation of Deep 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-23.

Repositories linked to this paper

More are linked than shown here.

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

Abstract

We propose prototypical networks for the problem of few-shot classification, where a classifier must generalize to new classes not seen in the training set, given only a small number of examples of each new class. Prototypical networks learn a metric space in which classification can be performed by computing distances to prototype representations of each class. Compared to recent approaches for few-shot learning, they reflect a simpler inductive bias that is beneficial in this limited-data regime, and achieve excellent results. We provide an analysis showing that some simple design decisions can yield substantial improvements over recent approaches involving complicated architectural choices and meta-learning. We further extend prototypical networks to zero-shot learning and achieve state-of-theart results on the CU-Birds dataset.

For agents

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

get_harvested_code_for_paper("1703.05175")
get_code_for_paper("1703.05175")
have("1703.05175")

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

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

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

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

Connect an agent — have() is free.