SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2103.05471 · CVPR · 2021

Contrastive Neural Architecture Search with Neural Architecture Comparators

Yong Guo, Mingkui Tan, Yaofo Chen, Qi Chen, Yaowei Wang, Wei Zeng, Minli Li

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 (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 0 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/2103.05471.json · badge: /api/ran/2103.05471.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
chenyaofo/CTNAS marked official in Papers with Code
Papers with Code archive
3 ran · 0 no recorded run
FunctionStatusWhere it lives
GCN Ran
ran on a synthesized input · constructed an object; no result was computed
chenyaofo/CTNAS/ctnas/core/model/nac.py
code served (permissive licence) · get_code("0174c3008a632396")
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 an instance of its own class, GCN: the run constructed the object and did not call it, so no result was computed. 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
import math

torch.manual_seed(0)

# Construct the GCN model
n_layers = 3
in_features = 4
hidden = 5
num_classes = 3

gcn_model = nn.Module()

# Create simple test tensors
# features: (batch_size, num_nodes, in_features)
# adj: (batch_size, num_nodes, num_nodes)
batch_size = 2
num_nodes = 6

x = torch.randn(batch_size, num_nodes, in_features)
adj = torch.randn(batch_size, num_nodes, num_nodes)

# Normalize adjacency matrix to reasonable range
adj = torch.sigmoid(adj)

ARGS = {
    'n_layers': n_layers,
    'in_features': in_features,
    'hidden': hidden,
    'num_classes': num_classes
}
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 GCN — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GCN 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
GraphConvolution Ran
ran on a synthesized input · constructed an object; no result was computed
chenyaofo/CTNAS/ctnas/core/model/nac.py
code served (permissive licence) · get_code("884806e1f859a018")
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 an instance of its own class, GraphConvolution: the run constructed the object and did not call it, so no result was computed. 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
import math

class GraphConvolution(nn.Module):

    def __init__(self, in_features, out_features, bias=True, residual=True):
        super(GraphConvolution, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.residual = residual
        self.weight = nn.Parameter(torch.Tensor(in_features, out_features))
        if bias:
            self.bias = nn.Parameter(torch.Tensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        stdv = 1.0 / math.sqrt(self.weight.size(1))
        self.weight.data.uniform_(-stdv, stdv)
        if self.bias is not None:
            self.bias.data.uniform_(-stdv, stdv)

    def forward(self, features, adj):
        adj = adj + torch.eye(adj.size(-1), device=adj.device)
        support = torch.matmul(features, self.weight)
        output = torch.bmm(adj, support)
        if self.residual:
            output = output + features
        if self.bias is not None:
            return output + self.bias
        else:
            return output

    def __repr__(self):
        return self.__class__.__name__ + ' (' + str(self.in_features) + ' -> ' + str(self.out_features) + ')'


torch.manual_seed(0)

in_features = 4
out_features = 3
bias = True
residual = True

gc = GraphConvolution(in_features=in_features, out_features=out_features, bias=bias, residual=residual)

batch_size = 2
num_nodes = 5

features = torch.randn(batch_size, num_nodes, in_features)
adj = torch.randn(batch_size, num_nodes, num_nodes)

ARGS = {
    'in_features': in_features,
    'out_features': out_features,
    'bias': bias,
    'residual': residual
}
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 GraphConvolution — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GraphConvolution 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
NAC Ran
ran on a synthesized input · constructed an object; no result was computed
chenyaofo/CTNAS/ctnas/core/model/nac.py
code served (permissive licence) · get_code("ac31f1aefc407834")
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 an instance of its own class, NAC: the run constructed the object and did not call it, so no result was computed. 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
import math

torch.manual_seed(0)

# Build minimal valid arguments for NAC
n_nodes = 5
n_ops = 3
n_layers = 2
ratio = 2
embedding_dim = 4

ARGS = {
    "n_nodes": n_nodes,
    "n_ops": n_ops,
    "n_layers": n_layers,
    "ratio": ratio,
    "embedding_dim": embedding_dim,
}

# Verify the setup by creating an instance and calling forward
nac = nn.Module.__new__(type('NAC', (nn.Module,), {}))

# Manually construct NAC to test arguments work
from torch.nn import Embedding, Linear, ModuleList, Parameter

class GraphConvolution(nn.Module):
    def __init__(self, in_features, out_features, bias=True, residual=True):
        super(GraphConvolution, self).__init__()
        self.in_features = in_features
        self.out_features = out_features
        self.residual = residual
        self.weight = nn.Parameter(torch.Tensor(in_features, out_features))
        if bias:
            self.bias = nn.Parameter(torch.Tensor(out_features))
        else:
            self.register_parameter('bias', None)
        self.reset_parameters()

    def reset_parameters(self):
        stdv = 1.0 / math.sqrt(self.weight.size(1))
        self.weight.data.uniform_(-stdv, stdv)
        if self.bias is not None:
            self.bias.data.uniform_(-stdv, stdv)

    def forward(self, features, adj):
        adj = adj + torch.eye(adj.size(-1), device=adj.device)
        support = torch.matmul(features, self.weight)
        output = torch.bmm(adj, support)
        if self.residual:
            output = output + features
        if self.bias is not None:
            return output + self.bias
        else:
            return output

class GCN(nn.Module):
    def __init__(self, n_layers, in_features, hidden, num_classes):
        super(GCN, self).__init__()
        assert n_layers >= 2
        self.layers = nn.ModuleList()
        for i in range(n_layers - 1):
            in_channels = in_features if i == 0 else hidden
            self.layers.append(GraphConvolution(in_channels, hidden))
        self.last_layer = GraphConvolution(hidden, num_classes)

    def forward(self, x, adj):
        for l in self.layers:
            x = torch.nn.functional.relu(l(x, adj))
        x = self.last_layer(x, adj)
        x = torch.nn.functional.relu(x)
        return x

class NAC(nn.Module):
    def __init__(self, n_nodes, n_ops, n_layers=2, ratio=2, embedding_dim=128):
        super(NAC, self).__init__()
        self.n_nodes = n_nodes
        self.n_ops = n_ops
        self.embedding = nn.Embedding(self.n_ops + 3, embedding_dim=embedding_dim)
        self.gcn = GCN(n_layers=n_layers, in_features=embedding_dim, hidden=embedding_dim, num_classes=embedding_dim)
        self.fc = nn.Linear(embedding_dim * ratio, 1, bias=True)

    def forward(self, arch0, arch1):
        feature = torch.cat([self.extract_features(arch0), self.extract_features(arch1)], dim=1)
        score = self.fc(feature).view(-1)
        probility = torch.sigmoid(score)
        return probility

    def extract_features(self, arch):
        if len(arch) == 2:
            matrix, op = arch
            return self._extract(matrix, op)
        else:
            nor_mat, nor_ops, red_mat, red_ops = arch
            nor_feature = self._extract(nor_mat, nor_ops)
            red_feature = self._extract(red_mat, red_ops)
            return torch.cat([nor_feature, red_feature], dim=1)

    def _extract(self, matrix, ops):
        ops = self.embedding(ops)
        feature = self.gcn(ops, matrix).mean(dim=1, keepdim=False)
        return feature

# Test instantiation
model = NAC(**ARGS)

# Create test inputs: arch0 and arch1, each with (matrix, ops)
batch_size = 2
seq_len = 5

# matrix: [batch, seq_len, seq_len] adjacency matrix
matrix0 = torch.randn(batch_size, seq_len, seq_len)
# ops: [batch, seq_len] operation indices (0 to n_ops+2)
ops0 = torch.randint(0, ARGS["n_ops"] + 3, (batch_size, seq_len))

matrix1 = torch.randn(batch_size, seq_len, seq_len)
ops1 = torch.randint(0, ARGS["n_ops"] + 3, (batch_size, seq_len))

arch0 = (matrix0, ops0)
arch1 = (matrix1, ops1)

# Forward pass to verify
output = model(arch0, arch1)
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 NAC — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a NAC 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

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, 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 3 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-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

One of the key steps in Neural Architecture Search (NAS) is to estimate the performance of candidate architectures. Existing methods either directly use the validation performance or learn a predictor to estimate the performance. However, these methods can be either computationally expensive or very inaccurate, which may severely affect the search efficiency and performance. Moreover, as it is very difficult to annotate architectures with accurate performance on specific tasks, learning a promising performance predictor is often non-trivial due to the lack of labeled data. In this paper, we argue that it may not be necessary to estimate the absolute performance for NAS. On the contrary, we may need only to understand whether an architecture is better than a baseline one. However, how to exploit this comparison information as the reward and how to well use the limited labeled data remains two great challenges. In this paper, we propose a novel Contrastive Neural Architecture Search (CTNAS) method which performs architecture search by taking the comparison results between architectures as the reward. Specifically, we design and learn a Neural Architecture Comparator (NAC) to compute the probability of candidate architectures being better than a baseline one. Moreover, we present a baseline updating scheme to improve the baseline iteratively in a curriculum learning manner. More critically, we theoretically show that learning NAC is equivalent to optimizing the ranking over architectures. Extensive experiments in three search spaces demonstrate the superiority of our CTNAS over existing methods.

For agents

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

get_harvested_code_for_paper("2103.05471")
get_code_for_paper("2103.05471")
have("2103.05471")

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

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

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

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

Connect an agent — have() is free.