SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1404.4661 · 2014

Learning Fine-grained Image Similarity with Deep Ranking

arXiv · PDF · Open in the Atlas

Code that ran

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

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1404.4661.json · badge: /api/ran/1404.4661.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
Ducvoccer/mildnet community (classifier label)
classifier basis not recorded on the link
9 ran · 1 no recorded run
FunctionStatusWhere it lives
accuracy_fn Ran
ran on a synthesized input
Ducvoccer/mildnet/trainer/accuracy.py
code served (permissive licence) · get_code("933a8d4076b7053d")
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 function. 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

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

# The function needs:
# - batch_size: an integer that determines how many triplets to process
# The returned accuracy function needs:
# - y_true: a tensor (not actually used in the function body)
# - y_pred: a tensor with shape (batch_size, embedding_dim) containing embeddings
#           grouped in triplets (query, positive, negative)

# Create test data
batch_size = 6  # Must be divisible by 3 for triplets
embedding_dim = 4

# Create y_pred tensor with shape (batch_size, embedding_dim)
# containing 2 triplets of query, positive, negative embeddings
y_pred = tf.constant([
    [0.1, 0.2, 0.3, 0.4],  # query 1
    [0.12, 0.22, 0.32, 0.42],  # positive 1
    [0.5, 0.6, 0.7, 0.8],  # negative 1
    [0.15, 0.25, 0.35, 0.45],  # query 2
    [0.17, 0.27, 0.37, 0.47],  # positive 2
    [0.9, 0.95, 0.85, 0.75],  # negative 2
], dtype=tf.float32)

# Create y_true tensor (not used but required)
y_true = tf.constant([
    [1.0, 0.0],
    [1.0, 0.0],
    [0.0, 1.0],
    [1.0, 0.0],
    [1.0, 0.0],
    [0.0, 1.0],
], dtype=tf.float32)

ARGS = {
    "batch_size": batch_size,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
bold_text Ran
ran on a synthesized input
Ducvoccer/mildnet/execute.py
code served (permissive licence) · get_code("935e055e7cfb64f7")
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

torch.manual_seed(0)

ARGS = {
    'text': 'Hello World'
}
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
get_layers_output_by_name Ran
ran on a synthesized input
Ducvoccer/mildnet/trainer/utils.py
code served (permissive licence) · get_code("7f9ed8bff2dec4b4")
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 torch
import torch.nn as nn

torch.manual_seed(0)

class MockLayer(nn.Module):
    def __init__(self, input_dim, output_dim):
        super().__init__()
        self.linear = nn.Linear(input_dim, output_dim)
        self.output = torch.randn(2, output_dim)
    
    def forward(self, x):
        return self.linear(x)

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.layers_dict = {}
        self.layer1 = MockLayer(4, 3)
        self.layer2 = MockLayer(4, 5)
        self.layers_dict['layer1'] = self.layer1
        self.layers_dict['layer2'] = self.layer2
    
    def get_layer(self, name):
        return self.layers_dict[name]

model = MockModel()
layer_names = ['layer1', 'layer2']

ARGS = {
    'model': model,
    'layer_names': layer_names
}
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 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
hinge_loss_fn Ran
ran on a synthesized input
Ducvoccer/mildnet/trainer/loss.py
code served (permissive licence) · get_code("7cd865a3008326b6")
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 function. 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
from tensorflow.keras import backend as K
import numpy as np

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

# batch_size parameter: the function iterates through y_pred in steps of 3,
# so we need batch_size to be divisible by 3. Use batch_size=6.
batch_size = 6

# Create y_pred tensor: shape should be (batch_size, embedding_dim)
# The function accesses y_pred[i+0], y_pred[i+1], y_pred[i+2] (triplets)
# and computes differences and sqrt of sum of squares
# Use embedding_dim=4 as specified
embedding_dim = 4
y_pred = tf.constant(
    np.random.randn(batch_size, embedding_dim).astype(np.float32),
    dtype=tf.float32
)

# Create y_true tensor (not actually used in the loss function body, but required signature)
y_true = tf.constant(
    np.random.randn(batch_size, embedding_dim).astype(np.float32),
    dtype=tf.float32
)

ARGS = {
    "batch_size": batch_size,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
hinge_new_loss_fn Ran
ran on a synthesized input
Ducvoccer/mildnet/trainer/loss.py
code served (permissive licence) · get_code("68ff342bcecec641")
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 function. 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
from tensorflow.keras import backend as K
import numpy as np

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

# The function expects:
# - batch_size: int parameter
# - y_true: tensor (used in the inner function but not actually used in the loss calculation)
# - y_pred: tensor of shape (batch_size, embedding_dim) containing embeddings

batch_size = 6

# Create dummy y_true tensor (not used in the loss but required by the function signature)
y_true = tf.constant(np.random.randn(batch_size, 4).astype(np.float32))

# Create y_pred tensor with embeddings
# Shape: (batch_size, embedding_dim) where embedding_dim=4
# The function processes triplets: (query, positive, negative) in groups of 3
y_pred = tf.constant(np.random.randn(batch_size, 4).astype(np.float32))

ARGS = {
    "batch_size": batch_size,
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
hinge_twice_loss_fn Ran
ran on a synthesized input
Ducvoccer/mildnet/trainer/loss.py
code served (permissive licence) · get_code("98ad5c847015bf7f")
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 function. 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
from tensorflow.keras import backend as K
import numpy as np

_EPSILON = K.epsilon()

def hinge_twice_loss_fn(batch_size):

    def hinge_twice_loss(y_true, y_pred):
        y_pred = K.clip(y_pred, _EPSILON, 1.0 - _EPSILON)
        loss = tf.convert_to_tensor(0, dtype=tf.float32)
        g = tf.constant(1.0, shape=[1], dtype=tf.float32)
        for i in range(0, batch_size, 3):
            try:
                q_embedding = y_pred[i + 0]
                p_embedding = y_pred[i + 1]
                n_embedding = y_pred[i + 2]
                D_q_p = K.sqrt(K.sum((q_embedding - p_embedding) ** 2))
                D_q_n = K.sqrt(K.sum((q_embedding - n_embedding) ** 2))
                loss = loss + g + D_q_p - D_q_n
            except:
                continue
        loss = loss / (batch_size / 6)
        zero = tf.constant(0.0, shape=[1], dtype=tf.float32)
        return tf.maximum(loss, zero)
    return hinge_twice_loss


batch_size = 6

y_true_data = np.random.rand(6, 4).astype(np.float32)
y_pred_data = np.random.rand(6, 4).astype(np.float32)

y_true = tf.convert_to_tensor(y_true_data)
y_pred = tf.convert_to_tensor(y_pred_data)

loss_fn = hinge_twice_loss_fn(batch_size)
result = loss_fn(y_true, y_pred)

ARGS = {
    "batch_size": 6
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
random_rotation Ran
ran on a synthesized input
Ducvoccer/mildnet/trainer/datagen.py
code served (permissive licence) · get_code("1f5d7aded9eed612")
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 ndarray, ndim 3, dtype family float, shape (3, 4, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import scipy.ndimage as ndi

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

# Create a small 3D numpy array (channels, height, width)
# Using distinct sizes: 3 channels, 4 height, 5 width
x = np.random.rand(3, 4, 5).astype(np.float32)

# Rotation range in degrees
rg = 15

# Row axis (height dimension)
row_axis = 1

# Column axis (width dimension)
col_axis = 2

# Channel axis
channel_axis = 0

# Fill mode for interpolation
fill_mode = 'nearest'

# Constant value for fill_mode='constant'
cval = 0.0

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

import numpy as np
import scipy.ndimage as ndi

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

# Create a small 3D numpy array (channels, height, width)
# Using distinct dimensions: 3 channels, 4 height, 5 width
x = np.random.rand(3, 4, 5).astype(np.float32)

# Define arguments for random_shear function
ARGS = {
    'x': x,
    'intensity': 0.3,
    'row_axis': 1,
    'col_axis': 2,
    'channel_axis': 0,
    'fill_mode': 'nearest',
    'cval': 0.0
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family float, shape (3, 4, 5) — shape (3, 4, 5) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
random_shift Ran
ran; our contract draft was wrong, not the code
Ducvoccer/mildnet/trainer/datagen.py
code served (permissive licence) · get_code("48f4dd970a599237")
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 ndarray, ndim 3, dtype family float, shape (3, 4, 5) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import scipy.ndimage as ndi

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

# Create a small 3D image tensor (channels, height, width)
# Using distinct dimensions: 3 channels, 4 height, 5 width
x = np.random.randn(3, 4, 5).astype(np.float32)

# Define arguments for random_shift function
ARGS = {
    'x': x,
    'wrg': 0.1,  # width shift range as fraction
    'hrg': 0.2,  # height shift range as fraction
    'row_axis': 1,  # index of height axis
    'col_axis': 2,  # index of width axis
    'channel_axis': 0,  # index of channel axis
    'fill_mode': 'nearest',  # fill mode for points outside boundaries
    'cval': 0.0,  # constant value for fill (used if fill_mode='constant')
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 3, dtype family float, shape (3, 4, 5) — shape (3, 4, 5) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
print_trainable_counts Not yet run
unverified (harvested, no recorded run)
Ducvoccer/mildnet/trainer/utils.py
code served (permissive licence) · get_code("6c3cb340ed94f4da")
How it ran

no invocation recorded.

Also present in other papers' code

Of 10 samples lifted from this paper's linked repositories, 10 carry a function identity and 0 do not. Of the 10 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 9 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
random_shift 1 other paper
1 later
1511.06422 (2015-11)
All you need is a good init

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

Repositories linked to this paper

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

Abstract

Learning fine-grained image similarity is a challenging task. It needs to capture between-class and within-class image differences. This paper proposes a deep ranking model that employs deep learning techniques to learn similarity metric directly from images.It has higher learning capability than models based on hand-crafted features. A novel multiscale network structure has been developed to describe the images effectively. An efficient triplet sampling algorithm is proposed to learn the model with distributed asynchronized stochastic gradient. Extensive experiments show that the proposed algorithm outperforms models based on hand-crafted visual features and deep classification models.

For agents

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

get_harvested_code_for_paper("1404.4661")
get_code_for_paper("1404.4661")
have("1404.4661")

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

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

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

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

Connect an agent — have() is free.