SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2103.14021 · ICCV · 2021

Orthogonal Projection Loss

Muzammal Naseer, Kanchana Ranasinghe, Salman Khan, Munawar Hayat, Shahbaz Khan, • Fahad

arXiv · PDF · Open in the Atlas

Code that ran

8 of 14 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; 1 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 1 failure of our instrument; 6 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/2103.14021.json · badge: /api/ran/2103.14021.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
kahnchana/opl canonical (classifier label)
classifier basis: census
8 ran · 6 no recorded run
FunctionStatusWhere it lives
conv1x1 Ran
ran on a synthesized input
kahnchana/opl/classification/cifar/models/common.py
code served (permissive licence) · get_code("b58e540015b99393")
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 Conv2d. 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": 64,
    "stride": 1,
    "groups": 1,
    "bias": 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 Conv2d — a Conv2d output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Conv2d 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
format_time Ran
ran; our contract draft was wrong, not the code
kahnchana/opl/label_noise/truncated_loss/utils.py
pointer only (licence: MIT); the stored copy get_code serves, from JunlinHan/YOCO, is pointer only (licence: NONE) · get_code("8d7ec010c29e813b")
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 JunlinHan/YOCO, and GitHub detected no licence in that repository 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.

get_activation_layer Ran
ran on a synthesized input
kahnchana/opl/classification/cifar/models/common.py
code served (permissive licence) · get_code("0df92bd15ff63da7")
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 ReLU. 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 inspect import isfunction

torch.manual_seed(0)

# Test with string activation
ARGS = {
    'activation': 'relu'
}

# Alternative test cases can be uncommented:
# ARGS = {'activation': 'relu6'}
# ARGS = {'activation': 'swish'}
# ARGS = {'activation': 'hswish'}
# ARGS = {'activation': 'sigmoid'}
# ARGS = {'activation': 'hsigmoid'}
# ARGS = {'activation': 'identity'}
# ARGS = {'activation': nn.ReLU(inplace=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 ReLU — a ReLU output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ReLU 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_network Ran
ran on a synthesized input
kahnchana/opl/classification/cifar/utils.py
code served (permissive licence) · get_code("8b6b7011fdc6d6c4")
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 DummyResNet56. 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
import sys

# Create a minimal stand-in for resnet56_cifar100
class DummyResNet56(nn.Module):
    def __init__(self):
        super().__init__()
        self.output = nn.Linear(64, 100)
    
    def forward(self, x):
        return self.output(x)

# Create a minimal stand-in for resnet110_cifar100
class DummyResNet110(nn.Module):
    def __init__(self):
        super().__init__()
        self.output = nn.Linear(64, 100)
    
    def forward(self, x):
        return self.output(x)

# Create a minimal RBFLogits stand-in
class RBFLogits(nn.Module):
    def __init__(self, feature_dim, class_num, scale, gamma):
        super().__init__()
        self.feature_dim = feature_dim
        self.class_num = class_num
        self.scale = scale
        self.gamma = gamma
    
    def forward(self, x):
        return x

# Patch the imports so they return our mock objects
class MockModels:
    @staticmethod
    def resnet56_cifar100(pretrained=False):
        return DummyResNet56()
    
    @staticmethod
    def resnet110_cifar100(pretrained=False):
        return DummyResNet110()

class MockLosses:
    RBFLogits = RBFLogits

sys.modules['models'] = type(sys)('models')
sys.modules['models.resnet_cifar'] = MockModels
sys.modules['losses'] = MockLosses

# Create args object with required attributes
class Args:
    def __init__(self, net='resnet56', rbf=False, gpu=False):
        self.net = net
        self.rbf = rbf
        self.gpu = gpu

ARGS = {
    'args': Args(net='resnet56', rbf=False, gpu=False)
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
losses, models, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DummyResNet56 — a DummyResNet56 output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DummyResNet56 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_training_dataloader Ran
ran on a synthesized input
kahnchana/opl/classification/cifar/utils.py
code served (permissive licence) · get_code("00216823ab0d5455")
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 DataLoader. 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 torchvision
import torchvision.transforms as transforms
from torch.utils.data import DataLoader, Dataset
from PIL import Image

torch.manual_seed(0)
np.random.seed(0)

# Create a minimal mock CIFAR100 dataset to avoid downloads
class MockCIFAR100(Dataset):
    def __init__(self, root='./data', train=True, download=False, transform=None, target_transform=None, mean=(0.5, 0.5, 0.5), std=(0.5, 0.5, 0.5), distortion=1.0):
        self.train = train
        self.transform = transform
        self.target_transform = target_transform
        self.root = root
        self.download = download
        # Create fake CIFAR100 data: 2 samples, 32x32x3 images, 100 classes
        self.data = np.random.randint(0, 256, (2, 32, 32, 3), dtype=np.uint8)
        self.targets = [0, 1]
        
    def __len__(self):
        return len(self.data)
    
    def __getitem__(self, idx):
        img = Image.fromarray(self.data[idx])
        target = self.targets[idx]
        if self.transform:
            img = self.transform(img)
        if self.target_transform:
            target = self.target_transform(target)
        return img, target

# Monkey-patch torchvision.datasets.CIFAR100 to use our mock
original_cifar100 = torchvision.datasets.CIFAR100
torchvision.datasets.CIFAR100 = MockCIFAR100

# Also patch AugCIFAR100 to use MockCIFAR100 as base
class AugCIFAR100(MockCIFAR100):
    def __init__(self, mean, std, distortion=1.0, *args, **kwargs):
        super(AugCIFAR100, self).__init__(*args, **kwargs)

        def get_color_distortion(s=distortion):
            color_jitter = transforms.ColorJitter(0.8 * s, 0.8 * s, 0.8 * s, 0.2 * s)
            rnd_color_jitter = transforms.RandomApply([color_jitter], p=0.8)
            rnd_gray = transforms.RandomGrayscale(p=0.2)
            color_distort = transforms.Compose([rnd_color_jitter, rnd_gray])
            return color_distort
        
        transform_train = transforms.Compose([
            transforms.RandomCrop(32, padding=4),
            transforms.RandomHorizontalFlip(),
            get_color_distortion(),
            transforms.RandomRotation(15),
            transforms.ToTensor(),
            transforms.Normalize(mean, std)
        ])
        self.transform = transform_train

    def __getitem__(self, index: int):
        img, target = (self.data[index], self.targets[index])
        img = Image.fromarray(img)
        img1 = self.transform(img)
        img2 = self.transform(img)
        if self.target_transform is not None:
            target = self.target_transform(target)
        return (img1, img2, target)

def get_training_dataloader(mean, std, batch_size=16, num_workers=2, shuffle=True, use_aug=False):
    """ return training dataloader """
    if use_aug:
        cifar100_training = AugCIFAR100(root='./data', train=True, download=True, mean=mean, std=std, distortion=0.8)
    else:
        def cifar_train_transform(mean_rgb=(0.4914, 0.4822, 0.4465), std_rgb=(0.2023, 0.1994, 0.201), jitter_param=0.4):
            return transforms.Compose([
                transforms.RandomCrop(size=32, padding=4),
                transforms.RandomHorizontalFlip(),
                transforms.ColorJitter(brightness=jitter_param, contrast=jitter_param, saturation=jitter_param),
                transforms.ToTensor(),
                transforms.Normalize(mean=mean_rgb, std=std_rgb)
            ])
        transform_train = cifar_train_transform()
        cifar100_training = torchvision.datasets.CIFAR100(root='./data', train=True, download=True, transform=transform_train)
    
    cifar100_training_loader = DataLoader(cifar100_training, shuffle=shuffle, num_workers=0, batch_size=batch_size)
    return cifar100_training_loader

ARGS = {
    'mean': (0.4914, 0.4822, 0.4465),
    'std': (0.2023, 0.1994, 0.201),
    'batch_size': 2,
    'num_workers': 0,
    'shuffle': True,
    'use_aug': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
PIL, numpy, torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
resnet18 Ran
ran on a synthesized input
kahnchana/opl/classification/imagenet/custom_models.py
code served (permissive licence) · get_code("7717ac5d21296e1f")
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 CustomResnet. 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 torchvision
from torchvision.models.resnet import BasicBlock

torch.manual_seed(0)

# Create a minimal test input tensor (batch_size=2, channels=3, height=4, width=4)
test_input = torch.randn(2, 3, 4, 4)

# Define ARGS with all parameters for resnet18
ARGS = {
    'pretrained': False,
    'progress': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CustomResnet — a CustomResnet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a CustomResnet 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
resnet50 Ran
ran on a synthesized input
kahnchana/opl/classification/imagenet/custom_models.py
code served (permissive licence) · get_code("fce444af256e4d53")
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 CustomResnet. 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 torchvision
import tempfile
import os

torch.manual_seed(0)

# Create a minimal checkpoint file for testing
checkpoint_data = {
    'state_dict': {}
}
temp_dir = tempfile.gettempdir()
ckpt_path = os.path.join(temp_dir, 'test_ckpt.pt')
torch.save(checkpoint_data, ckpt_path)

ARGS = {
    'pretrained': False,
    'progress': False,
    'freeze': False,
    'ckpt': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchvision — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type CustomResnet — a CustomResnet output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a CustomResnet 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
round_channels Ran
ran, honoured the contract we drafted
kahnchana/opl/classification/cifar/models/common.py
pointer only (licence: MIT); the stored copy get_code serves, from fdbtrs/ElasticFace, is pointer only (licence: NONE) · get_code("dd12981b28dec323")
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 fdbtrs/ElasticFace, and GitHub detected no licence in that repository 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.

covariance_loss Not yet run
unverified (harvested, no recorded run)
kahnchana/opl/classification/cifar/losses.py
pointer only (licence: MIT); the stored copy get_code serves, from iclr2024mcmi/ICLRMCMI, is pointer only (licence: NONE) · get_code("753c62e00dde9126")
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 iclr2024mcmi/ICLRMCMI, and GitHub detected no licence in that repository 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.

get_resnet Not yet run
unverified (harvested, no recorded run)
kahnchana/opl/classification/cifar/models/resnet.py
code served (permissive licence) · get_code("15f95876a5d31c2a")
How it ran

no invocation recorded.

get_resnet_cifar Not yet run
unverified (harvested, no recorded run)
kahnchana/opl/classification/cifar/models/resnet_cifar.py
code served (permissive licence) · get_code("874f5e34aef613bf")
How it ran

no invocation recorded.

get_test_dataloader Not yet run
unverified (harvested, no recorded run)
kahnchana/opl/classification/cifar/utils.py
code served (permissive licence) · get_code("98bd1c9bc8319ae9")
How it ran

no invocation recorded.

resnet20_cifar10 Not yet run
unverified (harvested, no recorded run)
kahnchana/opl/classification/cifar/models/resnet_cifar.py
code served (permissive licence) · get_code("f157ed0645abe79a")
How it ran

no invocation recorded.

resnet20_cifar100 Not yet run
unverified (harvested, no recorded run)
kahnchana/opl/classification/cifar/models/resnet_cifar.py
code served (permissive licence) · get_code("0b26b805c45c8d6d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 3 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 3 later) and 11 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
format_time 37 other papers
9 dated earlier, 28 later
1603.05027 (2016-03)
Identity Mappings in Deep Residual Networks
1605.07146 (2016-05)
Wide Residual Networks
1805.11327 (2018-05)
Lightweight Probabilistic Deep Networks
and 34 more not named here
round_channels 2 other papers
2 later
2308.04995 (2023-08)
IDiff-Face: Synthetic-based Face Recognition through Fizzy Identity-Conditioned Diffusion Models
2405.15020 (2024-05)
AdjointDEIS: Efficient Gradients for Diffusion Models
covariance_loss 1 other paper
1 later
2601.01484 (2026-01)
SGD-Based Knowledge Distillation with Bayesian Teachers: Theory and Guidelines

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

Deep neural networks have achieved remarkable performance on a range of classification tasks, with softmax crossentropy (CE) loss emerging as the de-facto objective function. The CE loss encourages features of a class to have a higher projection score on the true class-vector compared to the negative classes. However, this is a relative constraint and does not explicitly force different class features to be well-separated. Motivated by the observation that groundtruth class representations in CE loss are orthogonal (onehot encoded vectors), we develop a novel loss function termed 'Orthogonal Projection Loss' (OPL) which imposes orthogonality in the feature space. OPL augments the properties of CE loss and directly enforces inter-class separation alongside intra-class clustering in the feature space through orthogonality constraints on the mini-batch level. As compared to other alternatives of CE, OPL offers unique advantages e.g., no additional learnable parameters, does not require careful negative mining and is not sensitive to the batch size. Given the plug-and-play nature of OPL, we evaluate it on a diverse range of tasks including image recognition (CIFAR-100), large-scale classification (ImageNet), domain generalization (PACS) and few-shot learning (mini-ImageNet, CIFAR-FS, tiered-ImageNet and Meta-dataset) and demonstrate its effectiveness across the board. Furthermore, OPL offers better robustness against practical nuisances such as adversarial attacks and label noise. Code

For agents

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

get_harvested_code_for_paper("2103.14021")
get_code_for_paper("2103.14021")
have("2103.14021")

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

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

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

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

Connect an agent — have() is free.