SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2204.12511 · 2022

PolyLoss: A Polynomial Expansion Perspective of Classification Loss Functions

arXiv · PDF · Open in the Atlas

Code that ran

6 of 7 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 5 have no contract verdict; 1 failure of our instrument; 1 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/2204.12511.json · badge: /api/ran/2204.12511.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
jahongir7174/MaskRCNN community (classifier label)
classifier basis not recorded on the link
3 ran · 0 no recorded run
nachiket273/loss-tryout community (classifier label)
classifier basis not recorded on the link
2 ran · 1 no recorded run
yiyixuxu/polyloss-pytorch reimplementation (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
crossentropyfirstn Ran
ran on a synthesized input
nachiket273/loss-tryout/polynloss.py
code served (permissive licence) · get_code("f6b1da081133f2de")
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 torch.nn as nn

torch.manual_seed(0)

# Analyzing the function:
# - probs: iterated with zip, each prob is indexed with tgt and has .item() called
#   This suggests prob is a tensor of probabilities (likely 1D or can be indexed)
# - tgts: iterated with zip, each tgt is used as an index into prob
#   This suggests tgt is a scalar integer
# - n: integer for range
# - reduction: string, checked against 'mean', 'sum', 'none'
# 
# The function computes a loss for each (prob, tgt) pair and returns based on reduction
# losses needs .mean() and .sum() methods, so it should be a tensor not a list
# (the current code returns a list but calls .mean()/.sum() on it, which would fail)
# However, we need to construct valid inputs that match what the code expects

# Create small probability tensors (batch of 2, with 4 classes each)
# Each prob should be indexable with a target class index
probs = [
    torch.tensor([0.1, 0.2, 0.6, 0.1]),  # probabilities for 4 classes
    torch.tensor([0.3, 0.5, 0.1, 0.1])   # probabilities for 4 classes
]

# Create target indices (one per sample, valid indices into the prob tensors)
tgts = [2, 1]  # target class indices

# Standard parameters
n = 100
reduction = 'none'

ARGS = {
    'probs': probs,
    'tgts': tgts,
    'n': n,
    'reduction': reduction
}
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 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
focallossfirstn Ran
ran on a synthesized input
nachiket273/loss-tryout/polynloss.py
code served (permissive licence) · get_code("75f93a5098113ec2")
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)

# Analyze the function:
# - probs: iterated with zip, each prob is indexed by tgt and has .item() called
#   This suggests prob is a tensor of probabilities
# - tgts: iterated with zip, each tgt is used as an index into prob
#   This suggests tgt is a scalar index
# - gamma: used in arithmetic (gamma + i + 1)
# - n: range parameter, default 100
# - reduction: string parameter for how to aggregate losses

# The function expects:
# - probs: list of tensors (each tensor will be indexed by a scalar)
# - tgts: list of scalar indices
# - gamma: numeric value
# - n: integer
# - reduction: string ('none', 'mean', or 'sum')

# Create small tensors for probs - batch size 2, with 4 probability values each
probs = [
    torch.tensor([0.9, 0.1, 0.8, 0.2]),  # 4 elements, will be indexed by tgt
    torch.tensor([0.7, 0.3, 0.6, 0.4])   # 4 elements, will be indexed by tgt
]

# Create scalar targets that are valid indices into the prob tensors (0-3)
tgts = [0, 2]

# Gamma parameter
gamma = 2.0

# n parameter
n = 10

# reduction parameter
reduction = 'none'

ARGS = {
    'probs': probs,
    'tgts': tgts,
    'gamma': gamma,
    'n': n,
    'reduction': reduction
}
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
resize Ran
ran on a synthesized input
jahongir7174/MaskRCNN/utils/util.py
code served (permissive licence) · get_code("e6a94a5bc4d9e8f4")
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 random
import cv2
import numpy as np

# Create a sample image (height=480, width=640, 3 channels for BGR)
image = np.random.randint(0, 256, size=(480, 640, 3), dtype=np.uint8)

# Define image_size
image_size = 256

ARGS = {
    "image": image,
    "image_size": image_size,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
cv2, 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
to_one_hot Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
yiyixuxu/polyloss-pytorch/PolyLoss.py
pointer only (licence: NONE) · get_code("6806c813ec675aab")
How it ran

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

xy2wh Ran
ran on a synthesized input
jahongir7174/MaskRCNN/utils/util.py
code served (permissive licence) · get_code("9ead510a24af1caa")
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 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 numpy

# The function xy2wh takes a single parameter 'x' which is a numpy array
# It performs operations on x assuming it has shape (N, 4) where N is batch size
# The operations: converts from (x1, y1, x2, y2) format to (center_x, center_y, width, height) format

# Create a small numpy array with shape (2, 4) - 2 bounding boxes with 4 coordinates each
x = numpy.array([
    [10.0, 20.0, 50.0, 80.0],
    [5.0, 15.0, 35.0, 65.0]
], dtype=numpy.float32)

ARGS = {
    'x': x
}
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 ndarray, 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
xyn2xy Ran
ran on a synthesized input
jahongir7174/MaskRCNN/utils/util.py
code served (permissive licence) · get_code("e79b32bd70ec5c58")
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 2, dtype family float, shape (2, 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

numpy.random.seed(0)

# The function xyn2xy takes normalized coordinates (x) and denormalizes them
# using width (w), height (h), and padding values (pad_w, pad_h)
# x should be a 2D array where each row is [x_coord, y_coord] in normalized form
# w, h are scalar dimensions
# pad_w, pad_h are scalar padding offsets

x = numpy.array([
    [0.5, 0.3],
    [0.2, 0.8]
], dtype=numpy.float32)

w = 640
h = 480
pad_w = 10
pad_h = 20

ARGS = {
    "x": x,
    "w": w,
    "h": h,
    "pad_w": pad_w,
    "pad_h": pad_h
}
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 ndarray, ndim 2, dtype family float, shape (2, 2) — shape (2, 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
polynloss Not yet run
unverified (harvested, no recorded run)
nachiket273/loss-tryout/polynloss.py
code served (permissive licence) · get_code("f31e8ddcecd510f0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 7 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.

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

Cross-entropy loss and focal loss are the most common choices when training deep neural networks for classification problems. Generally speaking, however, a good loss function can take on much more flexible forms, and should be tailored for different tasks and datasets. Motivated by how functions can be approximated via Taylor expansion, we propose a simple framework, named PolyLoss, to view and design loss functions as a linear combination of polynomial functions. Our PolyLoss allows the importance of different polynomial bases to be easily adjusted depending on the targeting tasks and datasets, while naturally subsuming the aforementioned cross-entropy loss and focal loss as special cases. Extensive experimental results show that the optimal choice within the PolyLoss is indeed dependent on the task and dataset. Simply by introducing one extra hyperparameter and adding one line of code, our Poly-1 formulation outperforms the cross-entropy loss and focal loss on 2D image classification, instance segmentation, object detection, and 3D object detection tasks, sometimes by a large margin.

For agents

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

get_harvested_code_for_paper("2204.12511")
get_code_for_paper("2204.12511")
have("2204.12511")

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

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

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

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

Connect an agent — have() is free.