SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2206.01909 · 2022

Toward Learning Robust and Invariant Representations with Alignment Regularization and Data Augmentation

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 9 have no contract verdict; 0 failures 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/2206.01909.json · badge: /api/ran/2206.01909.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
jyanln/alignreg canonical (classifier label)
classifier basis not recorded on the link
9 ran · 1 no recorded run
FunctionStatusWhere it lives
measure_acc Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/tf_training.py
code served (permissive licence) · get_code("0f976d4063cfd225")
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 float32, ndim 0, dtype family float, shape () 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 tensorflow as tf
import tensorflow.keras as keras
import numpy as np

# Create a simple model that takes images and outputs class predictions
class SimpleModel(keras.Model):
    def __init__(self):
        super(SimpleModel, self).__init__()
        self.dense = keras.layers.Dense(5)  # 5 output classes
    
    def call(self, inputs, training=False):
        return self.dense(inputs)

# Create model instance
model = SimpleModel()

# Create small batch of images (batch_size=2, feature_dim=4)
images = tf.constant(np.random.randn(2, 4).astype(np.float32))

# Create labels (batch_size=2, with class indices 0-4)
labels = tf.constant([0, 2], dtype=tf.int64)

# Create accuracy metric
accuracy_metric = keras.metrics.Accuracy()

# Create test_data as a list of (images, labels) batches
test_data = [
    (tf.constant(np.random.randn(2, 4).astype(np.float32)), tf.constant([1, 3], dtype=tf.int64)),
    (tf.constant(np.random.randn(2, 4).astype(np.float32)), tf.constant([0, 4], dtype=tf.int64))
]

ARGS = {
    "model": model,
    "images": images,
    "labels": labels,
    "accuracy_metric": accuracy_metric,
    "test_data": test_data
}
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 float32, ndim 0, dtype family float, shape () — shape () 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
measure_acc Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/torch_training.py
code served (permissive licence) · get_code("cedf86827992a115")
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 float, ndim 0, dtype family float, shape () 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 torch
import torch.nn as nn

torch.manual_seed(0)

# Define a minimal model that takes images and outputs logits
class SimpleClassifier(nn.Module):
    def __init__(self, num_classes=3):
        super().__init__()
        self.linear = nn.Linear(4, num_classes)
    
    def forward(self, x):
        # x shape: (batch_size, 4)
        return self.linear(x)

# Create model instance
model = SimpleClassifier(num_classes=3)
model.eval()

# Create a simple testloader as a list of (images, labels) tuples
# Each image is a tensor of shape (batch_size, 4)
# Each label is a tensor of shape (batch_size,) with class indices
testloader = [
    (torch.randn(2, 4), torch.tensor([0, 1])),
    (torch.randn(2, 4), torch.tensor([2, 0])),
    (torch.randn(2, 4), torch.tensor([1, 2])),
]

# num_batch parameter: -1 means use all batches
num_batch = -1

ARGS = {
    "model": model,
    "testloader": testloader,
    "num_batch": num_batch,
}
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 float, ndim 0, dtype family float, shape () — shape () 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
tf_contrast Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/augment.py
code served (permissive licence) · get_code("ec58444897d53c3d")
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

# The function tf_contrast takes a parameter 'c' which is a contrast factor
# It returns a lambda that adjusts the contrast of an image
# The contrast factor is typically a float value

# Create a small test image (batch_size=2, height=4, width=3, channels=3)
# TensorFlow expects images as tensors with values typically in [0, 1] or [0, 255]
test_image = tf.constant(np.random.rand(2, 4, 3, 3).astype(np.float32))

# The contrast factor 'c' should be a float
# Values > 1 increase contrast, < 1 decrease it
contrast_factor = 1.5

ARGS = {
    "c": contrast_factor
}
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
tf_maxsql2 Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/regularization.py
code served (permissive licence) · get_code("c2c0cb5c6871d8ca")
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 EagerTensor, ndim 0, dtype family float, shape () 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 tensorflow as tf
import numpy as np

# Create a simple TensorFlow model
class SimpleModel(tf.keras.Model):
    def __init__(self):
        super(SimpleModel, self).__init__()
        self.dense = tf.keras.layers.Dense(5)
    
    def call(self, x, training=False):
        return self.dense(x)

# Create model instance
model = SimpleModel()

# Create tiny tensors for images (batch_size=2, features=4)
images = tf.constant(np.random.randn(2, 4).astype(np.float32))

# Create augmented image sets - list of batches with augmentations applied
aug_image_sets = [
    tf.constant(np.random.randn(2, 4).astype(np.float32)),
    tf.constant(np.random.randn(2, 4).astype(np.float32))
]

# Create a simple loss function
def loss_fn(labels, logits):
    return tf.reduce_mean(tf.keras.losses.sparse_categorical_crossentropy(labels, logits, from_logits=True))

# Create labels (batch_size=2, with class indices)
labels = tf.constant([0, 1])

# Lambda parameter for regularization
l2_lambda = 0.5

ARGS = {
    "model": model,
    "images": images,
    "aug_image_sets": aug_image_sets,
    "loss_fn": loss_fn,
    "labels": labels,
    "l2_lambda": l2_lambda
}
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 EagerTensor, ndim 0, dtype family float, shape () — shape () 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
tf_saturation Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/augment.py
code served (permissive licence) · get_code("7c0fd59e3ff2fb84")
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)

# Create a small test image tensor
# TensorFlow image tensors are typically (height, width, channels)
# Using shape (4, 3, 3) for height=4, width=3, channels=3 (RGB)
test_image = tf.constant(np.random.rand(4, 3, 3).astype(np.float32))

# The function tf_saturation takes parameter 'c' (saturation factor)
# and returns a lambda that adjusts saturation of an image
# c is typically a float value where 1.0 is normal saturation
c_value = 1.5

ARGS = {
    "c": c_value
}
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
tf_sql2 Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/regularization.py
code served (permissive licence) · get_code("12f9b449a86412ad")
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 EagerTensor, ndim 0, dtype family float, shape () 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 tensorflow as tf
import numpy as np

# Create a minimal TensorFlow model
class SimpleModel(tf.keras.Model):
    def __init__(self):
        super(SimpleModel, self).__init__()
        self.dense = tf.keras.layers.Dense(4)
    
    def call(self, inputs, training=False):
        return self.dense(inputs)

# Instantiate the model
model = SimpleModel()

# Create tiny tensors: batch size 2, feature dimension 3
images = tf.constant(np.random.randn(2, 3).astype(np.float32))
aug_images = tf.constant(np.random.randn(2, 3).astype(np.float32))

ARGS = {
    "model": model,
    "images": images,
    "aug_images": aug_images
}
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 EagerTensor, ndim 0, dtype family float, shape () — shape () 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
torch_rotate Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/augment.py
code served (permissive licence) · get_code("526d47316be4a71f")
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 torch
import torchvision.transforms.functional as torch_transforms
from PIL import Image
import numpy as np

torch.manual_seed(0)

# Create a small PIL Image to pass to the rotate function
# torch_transforms.rotate expects a PIL Image
img_array = np.random.randint(0, 256, (4, 3, 3), dtype=np.uint8)
pil_img = Image.fromarray(img_array[0])

# The function torch_rotate(r) returns a lambda that calls torch_transforms.rotate(img, r)
# r is the rotation angle in degrees
r = 45

ARGS = {
    "r": r
}
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 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
torch_sql2 Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/regularization.py
code served (permissive licence) · get_code("43896c01fecbf540")
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 Tensor, ndim 0, dtype family float, shape () 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 torch
import torch.nn as nn

torch.manual_seed(0)

# Define a simple model that takes an image and returns logits
class SimpleModel(nn.Module):
    def __init__(self, input_size=3, output_size=4):
        super().__init__()
        self.linear = nn.Linear(input_size, output_size)
    
    def forward(self, x):
        # Flatten input and pass through linear layer
        batch_size = x.shape[0]
        x_flat = x.view(batch_size, -1)
        return self.linear(x_flat)

# Create model instance
model = SimpleModel(input_size=12, output_size=4)

# Create tiny image tensors: batch_size=2, channels=3, height=2, width=2
# Total elements per image: 2*3*2*2 = 24 -> will be flattened to 12
image = torch.randn(2, 3, 2, 2)
aug_image = torch.randn(2, 3, 2, 2)

ARGS = {
    "model": model,
    "image": image,
    "aug_image": aug_image
}
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 Tensor, ndim 0, dtype family float, shape () — shape () 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
torch_train Ran
ran on a synthesized input
jyanln/alignreg/src/alignreg/torch_training.py
code served (permissive licence) · get_code("66f18a7f2b57b4a3")
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 torch
import torch.nn as nn
from torch.optim import SGD

torch.manual_seed(0)

# Define a simple model
class SimpleModel(nn.Module):
    def __init__(self):
        super(SimpleModel, self).__init__()
        self.fc1 = nn.Linear(4, 8)
        self.fc2 = nn.Linear(8, 3)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

# Create model instance
model = SimpleModel()

# Create optimizer
optimizer = SGD(model.parameters(), lr=0.01)

# Create loss function
loss_fn = nn.CrossEntropyLoss()

# Create train_loader with (images, aug_images, label) tuples
train_loader = [
    (torch.randn(2, 4), torch.randn(2, 4), torch.randint(0, 3, (2,))),
    (torch.randn(2, 4), torch.randn(2, 4), torch.randint(0, 3, (2,))),
]

# Create test_loader with (images, labels) tuples for measure_acc
test_loader = [
    (torch.randn(2, 4), torch.randint(0, 3, (2,))),
    (torch.randn(2, 4), torch.randint(0, 3, (2,))),
]

# Define a simple augmentation function
def simple_augment(x):
    return x + torch.randn_like(x) * 0.1

# Define torch_maxsql2 stub function needed by torch_train
def torch_maxsql2(model, images, aug_images, loss_fn, label, l2_lambda):
    return torch.tensor(0.0)

# Make it available in the module namespace
import sys
current_module = sys.modules[__name__]
setattr(current_module, 'torch_maxsql2', torch_maxsql2)

ARGS = {
    'train_loader': train_loader,
    'test_loader': test_loader,
    'model': model,
    'optimizer': optimizer,
    'epochs': 2,
    'loss_fn': loss_fn,
    'l2_lambda': 0.01,
    'record_batch_size': 1,
    'acc_batch': -1,
    'lazy_augmentations': [],
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
train_step Not yet run
unverified (harvested, no recorded run)
jyanln/alignreg/src/alignreg/tf_training.py
code served (permissive licence) · get_code("b4c6a8550e4357bf")
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, 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 10 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

Data augmentation has been proven to be an effective technique for developing machine learning models that are robust to known classes of distributional shifts (e.g., rotations of images), and alignment regularization is a technique often used together with data augmentation to further help the model learn representations invariant to the shifts used to augment the data. In this paper, motivated by a proliferation of options of alignment regularizations, we seek to evaluate the performances of several popular design choices along the dimensions of robustness and invariance, for which we introduce a new test procedure. Our synthetic experiment results speak to the benefits of squared l2 norm regularization. Further, we also formally analyze the behavior of alignment regularization to complement our empirical study under assumptions we consider realistic. Finally, we test this simple technique we identify (worst-case data augmentation with squared l2 norm alignment regularization) and show that the benefits of this method outrun those of the specially designed methods. We also release a software package in both TensorFlow and PyTorch for users to use the method with a couple of lines at https://github.com/jyanln/AlignReg.

For agents

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

get_harvested_code_for_paper("2206.01909")
get_code_for_paper("2206.01909")
have("2206.01909")

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

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

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

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

Connect an agent — have() is free.