SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1805.10123 · 2018

TADAM: Task dependent adaptive metric for improved few-shot learning

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 7 have no contract verdict; 0 failures of our instrument; 2 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1805.10123.json · badge: /api/ran/1805.10123.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
ElementAI/TADAM community (classifier label)
classifier basis not recorded on the link
7 ran · 2 no recorded run
FunctionStatusWhere it lives
find_variables Ran
ran on a synthesized input
ElementAI/TADAM/common/gen_experiments.py
code served (permissive licence) · get_code("cbbf64827d3199c5")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import numpy as np

torch.manual_seed(0)

# The function find_variables takes a param_dict and looks for list values
# It iterates through key-value pairs and checks if values are lists
# So we need to construct a dictionary with various types of values,
# including some lists and some non-list values

param_dict = {
    "learning_rate": 0.001,
    "batch_size": 32,
    "layer_sizes": [64, 128, 256],
    "activation": "relu",
    "hidden_dims": [512, 256, 128],
    "dropout": 0.5,
    "epochs": [10, 20, 30],
    "model_name": "transformer",
    "filters": [32, 64, 128, 256]
}

ARGS = {
    "param_dict": param_dict
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_image_size Ran
ran on a synthesized input
ElementAI/TADAM/model/tadam.py
code served (permissive licence) · get_code("4109ef235133a0b8")
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 int, ndim 0, dtype family int, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

# The function get_image_size takes a data_dir parameter (a string path)
# and returns an image size based on which dataset name is in the path.
# It uses simple string matching with 'in' operator.

ARGS = {
    'data_dir': 'mini-imagenet'
}
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 int, ndim 0, dtype family int, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
get_logdir_name Ran
ran on a synthesized input
ElementAI/TADAM/model/tadam.py
code served (permissive licence) · get_code("c6ffd4890568d5b5")
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 str. 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.

class Flags:
    def __init__(self):
        self.train_batch_size = 32
        self.num_tasks_per_batch = 4
        self.init_learning_rate = 0.001
        self.lr_anneal = 'exponential'
        self.optimizer = 'adam'
        self.weight_decay = 0.0001
        self.num_filters = 64
        self.feature_extractor = 'conv'
        self.metric = 'accuracy'
        self.log_dir = ''
        self.exp_dir = None

ARGS = {
    'flags': Flags()
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
load_and_save_params Ran
ran on a synthesized input
ElementAI/TADAM/common/gen_experiments.py
code served (permissive licence) · get_code("e6d118defb0d5895")
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 dict. 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 os
import json
import tempfile
import logging

logging.basicConfig(level=logging.INFO)

default_params = {
    "learning_rate": 0.001,
    "batch_size": 32,
    "num_epochs": 10,
    "model_type": "transformer"
}

exp_dir = tempfile.mkdtemp()

ARGS = {
    "default_params": default_params,
    "exp_dir": exp_dir,
    "ignore_existing": False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
make_experiment_name Ran
ran on a synthesized input
ElementAI/TADAM/common/gen_experiments.py
code served (permissive licence) · get_code("fbc88036d44ff13c")
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 str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# The function make_experiment_name takes an experiment parameter
# which is a dict where it iterates over items()
# It checks if values are floats and formats them accordingly
# All values are converted to strings

experiment = {
    'learning_rate': 0.001,
    'batch_size': 32,
    'num_epochs': 100,
    'model_name': 'resnet50',
    'dropout': 0.5,
    'activation': 'relu',
    'weight_decay': 1e-4,
    'optimizer': 'adam'
}

ARGS = {
    'experiment': experiment
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
make_task Ran
ran on a synthesized input
ElementAI/TADAM/datasets/data.py
code served (permissive licence) · get_code("d98246181e886b12")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

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

# Create sample labels data
# Simulate a mini-imagenet-like dataset with multiple classes
# Let's create labels for 100 samples across 10 different classes
labels = np.array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 
                    2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
                    4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
                    6, 6, 6, 6, 6, 7, 7, 7, 7, 7,
                    8, 8, 8, 8, 8, 9, 9, 9, 9, 9,
                    0, 0, 0, 1, 1, 1, 2, 2, 2, 3,
                    3, 3, 4, 4, 4, 5, 5, 5, 6, 6,
                    6, 7, 7, 7, 8, 8, 8, 9, 9, 9,
                    0, 0, 1, 1, 2, 2, 3, 3, 4, 4,
                    5, 5, 6, 6, 7, 7, 8, 8, 9, 9], dtype=np.int32)

# Parameters for make_task
n_samples_per_class = 3  # number of training samples per class
n_classes_per_task = 4   # number of classes to sample for the task
rng = np.random.RandomState(42)  # Random number generator with seed

ARGS = {
    'labels': labels,
    'n_samples_per_class': n_samples_per_class,
    'n_classes_per_task': n_classes_per_task,
    'rng': rng
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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
variables_by_name Ran
ran on a synthesized input
ElementAI/TADAM/common/util.py
code served (permissive licence) · get_code("48280b7cf494bec4")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tensorflow as tf
import numpy as np

# Enable eager execution for TensorFlow 1.x compatibility
tf.compat.v1.enable_eager_execution()

# Create some test variables with different names
var1 = tf.Variable(np.random.randn(2, 4).astype(np.float32), name='dense_layer_weights')
var2 = tf.Variable(np.random.randn(4).astype(np.float32), name='dense_layer_bias')
var3 = tf.Variable(np.random.randn(3, 5).astype(np.float32), name='conv_kernel')
var4 = tf.Variable(np.random.randn(5).astype(np.float32), name='conv_bias')

# Create a list of variables to search through
variable_list = [var1, var2, var3, var4]

# Define the pattern to match - will match variables with "dense_layer" in their name
pattern = "*/dense_layer*"

ARGS = {
    'pattern': pattern,
    'variable_list': variable_list
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unique_variable_by_name Not yet run
unverified (harvested, no recorded run)
ElementAI/TADAM/common/util.py
code served (permissive licence) · get_code("1618d44f2e0a214e")
How it ran

no invocation recorded.

variable_report Not yet run
unverified (harvested, no recorded run)
ElementAI/TADAM/common/util.py
code served (permissive licence) · get_code("7d1301d4ad8cb6c4")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 7 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 7 later) and 2 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
find_variables 1 other paper
1 later
1902.07104 (2019-02)
Adaptive Cross-Modal Few-Shot Learning
load_and_save_params 1 other paper
1 later
1902.07104 (2019-02)
Adaptive Cross-Modal Few-Shot Learning
make_experiment_name 1 other paper
1 later
1902.07104 (2019-02)
Adaptive Cross-Modal Few-Shot Learning
make_task 1 other paper
1 later
1902.07104 (2019-02)
Adaptive Cross-Modal Few-Shot Learning
unique_variable_by_name 1 other paper
1 later
1902.07104 (2019-02)
Adaptive Cross-Modal Few-Shot Learning
variable_report 1 other paper
1 later
1902.07104 (2019-02)
Adaptive Cross-Modal Few-Shot Learning
variables_by_name 1 other paper
1 later
1902.07104 (2019-02)
Adaptive Cross-Modal Few-Shot Learning

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

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

Abstract

Few-shot learning has become essential for producing models that generalize from few examples. In this work, we identify that metric scaling and metric task conditioning are important to improve the performance of few-shot algorithms. Our analysis reveals that simple metric scaling completely changes the nature of few-shot algorithm parameter updates. Metric scaling provides improvements up to 14% in accuracy for certain metrics on the mini-Imagenet 5-way 5-shot classification task. We further propose a simple and effective way of conditioning a learner on the task sample set, resulting in learning a task-dependent metric space. Moreover, we propose and empirically test a practical end-to-end optimization procedure based on auxiliary task co-training to learn a task-dependent metric space. The resulting few-shot learning model based on the task-dependent scaled metric achieves state of the art on mini-Imagenet. We confirm these results on another few-shot dataset that we introduce in this paper based on CIFAR100. Our code is publicly available at https://github.com/ElementAI/TADAM.

For agents

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

get_harvested_code_for_paper("1805.10123")
get_code_for_paper("1805.10123")
have("1805.10123")

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

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

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

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

Connect an agent — have() is free.