SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1901.09054 · 2019

Deep Learning on Small Datasets without Pre-Training using Cosine Loss

arXiv · PDF · Open in the Atlas

Code that ran

3 of 3 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, 1 violated it and 0 have no contract verdict; 2 failures of our instrument; 0 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1901.09054.json · badge: /api/ran/1901.09054.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
cvjena/semantic-embeddings canonical (classifier label)
classifier basis: classifier_2025
3 ran · 0 no recorded run
FunctionStatusWhere it lives
euclidean_embedding Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cvjena/semantic-embeddings/compute_class_embedding.py
code served (permissive licence) · get_code("1f726f5ea616424c")
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 ndarray, ndim 2, dtype family float, shape (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 numpy as np
import scipy.linalg
import scipy.spatial.distance

# Create a valid distance matrix for 4 classes
# We'll use a simple metric that satisfies triangle inequality
# Start with a simple symmetric distance matrix
class_dist = np.array([
    [0.0, 1.0, 2.0, 2.5],
    [1.0, 0.0, 1.5, 2.0],
    [2.0, 1.5, 0.0, 1.0],
    [2.5, 2.0, 1.0, 0.0]
], dtype=np.float64)

# Verify it's symmetric and has zeros on diagonal
assert np.allclose(class_dist, class_dist.T), "Distance matrix must be symmetric"
assert np.allclose(np.diag(class_dist), 0), "Diagonal must be zero"

# Verify triangle inequality holds (approximately, for numerical stability)
n = class_dist.shape[0]
for i in range(n):
    for j in range(n):
        for k in range(n):
            # d(i,k) <= d(i,j) + d(j,k)
            assert class_dist[i, k] <= class_dist[i, j] + class_dist[j, k] + 1e-10, \
                f"Triangle inequality violated for {i}, {j}, {k}"

ARGS = {
    'class_dist': class_dist,
    'solver': 'general'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 2, dtype family float, shape (4, 3) — shape (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
sim_approx Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
cvjena/semantic-embeddings/compute_class_embedding.py
code served (permissive licence) · get_code("234d5f2d97a6f36f")
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 ndarray, ndim 2, dtype family float, shape (4, 2) 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

# Create a simple positive semi-definite similarity matrix
# Using a 4x4 matrix for class similarities
n_classes = 4
class_sim = np.array([
    [1.0, 0.8, 0.6, 0.4],
    [0.8, 1.0, 0.7, 0.5],
    [0.6, 0.7, 1.0, 0.6],
    [0.4, 0.5, 0.6, 1.0]
], dtype=np.float32)

# Ensure it's positive semi-definite by using eigendecomposition
L, Q = np.linalg.eigh(class_sim)
L = np.maximum(L, 0)  # Clamp negative eigenvalues to 0
class_sim = Q @ np.diag(L) @ Q.T

# Set target dimensionality to be less than n
num_dim = 2

ARGS = {
    'class_sim': class_sim,
    'num_dim': num_dim
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (4, 2) — shape (4, 2) 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
unitsphere_embedding Ran
ran, violated the contract we drafted
cvjena/semantic-embeddings/compute_class_embedding.py
code served (permissive licence) · get_code("f83a7b7243eb16a4")
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 ndarray, ndim 2, dtype family float, shape (4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np

# Create a valid class similarity matrix
# For a unit sphere embedding to work, the similarity matrix must be
# symmetric and have specific properties (positive semi-definite with
# diagonal elements equal to 1.0)

n = 4
class_sim = np.array([
    [1.0,  0.8,  0.6,  0.4],
    [0.8,  1.0,  0.7,  0.5],
    [0.6,  0.7,  1.0,  0.6],
    [0.4,  0.5,  0.6,  1.0]
], dtype=np.float64)

ARGS = {
    'class_sim': class_sim
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (4, 4) — shape (4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block

Also present in other papers' code

Of 3 samples lifted from this paper's linked repositories, 3 carry a function identity and 0 do not. Of the 3 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 0 later) and 0 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_embedding 1 other paper
1 dated earlier
1809.09924 (2018-09)
Hierarchy-based Image Embeddings for Semantic Image Retrieval
sim_approx 1 other paper
1 dated earlier
1809.09924 (2018-09)
Hierarchy-based Image Embeddings for Semantic Image Retrieval
unitsphere_embedding 1 other paper
1 dated earlier
1809.09924 (2018-09)
Hierarchy-based Image Embeddings for Semantic Image Retrieval

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

Two things seem to be indisputable in the contemporary deep learning discourse: 1. The categorical cross-entropy loss after softmax activation is the method of choice for classification. 2. Training a CNN classifier from scratch on small datasets does not work well. In contrast to this, we show that the cosine loss function provides significantly better performance than cross-entropy on datasets with only a handful of samples per class. For example, the accuracy achieved on the CUB-200-2011 dataset without pre-training is by 30% higher than with the cross-entropy loss. Further experiments on other popular datasets confirm our findings. Moreover, we demonstrate that integrating prior knowledge in the form of class hierarchies is straightforward with the cosine loss and improves classification performance further.

For agents

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

get_harvested_code_for_paper("1901.09054")
get_code_for_paper("1901.09054")
have("1901.09054")

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

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

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

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

Connect an agent — have() is free.