SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1910.06922 · 2019

Gradient penalty from a maximum margin perspective

arXiv · PDF · Open in the Atlas

Code that ran

6 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, 1 violated it and 2 have no contract verdict; 3 failures of our instrument; 4 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/1910.06922.json · badge: /api/ran/1910.06922.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
AlexiaJM/MaximumMarginGANs canonical (classifier label)
classifier basis: census
6 ran · 4 no recorded run
FunctionStatusWhere it lives
calculate_frechet_distance Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
AlexiaJM/MaximumMarginGANs/Code/fid.py
pointer only (licence: MIT); the stored copy get_code serves, from huangjiadidi/PUGAN, is pointer only (licence: NONE) · get_code("7e61fe013d57c481")
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 huangjiadidi/PUGAN, 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.

calculate_frechet_distance Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
AlexiaJM/MaximumMarginGANs/Code/fid_new.py
code served (permissive licence) · get_code("846d824d45774de9")
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 float64, ndim 0, 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 numpy as np
from scipy import linalg
import warnings

# Set random seed for reproducibility
np.random.seed(0)

# Create small sample data for Frechet Distance calculation
# The function expects mean vectors and covariance matrices from activation distributions

# Dimension of activation space (e.g., from Inception network pool_3 layer)
activation_dim = 4

# Number of samples for computing statistics
num_samples = 2

# Generate sample activations for two distributions
activations1 = np.random.randn(num_samples, activation_dim)
activations2 = np.random.randn(num_samples, activation_dim)

# Compute mean vectors
mu1 = np.mean(activations1, axis=0)  # shape: (4,)
mu2 = np.mean(activations2, axis=0)  # shape: (4,)

# Compute covariance matrices
sigma1 = np.cov(activations1.T)  # shape: (4, 4)
sigma2 = np.cov(activations2.T)  # shape: (4, 4)

# Ensure covariance matrices are positive definite by adding small regularization
epsilon = 1e-6
sigma1 = sigma1 + epsilon * np.eye(activation_dim)
sigma2 = sigma2 + epsilon * np.eye(activation_dim)

ARGS = {
    'mu1': mu1,
    'sigma1': sigma1,
    'mu2': mu2,
    'sigma2': sigma2,
    'eps': 1e-06
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float64, ndim 0, dtype family float — no output shape is stated: observe_signature.py recorded float ndim 0, which disagrees with the fixture run
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
make_dot Ran
ran; our contract draft was wrong, not the code
AlexiaJM/MaximumMarginGANs/Code/pytorch_visualize.py
code served (permissive licence) · get_code("52a3f79b47513c42")
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 Digraph. 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)

# Create a simple computational graph
x = torch.randn(2, 4, requires_grad=True)
w = torch.randn(4, 3, requires_grad=True)

# Perform some operations to build autograd graph
y = torch.matmul(x, w)
z = y.sum()
z.backward()

# Create params dict with named variables
params = {
    'x': x,
    'w': w,
}

# The function expects:
# - var: output Variable (the result of operations with grad_fn)
# - params: dict mapping names to variables that require grad

ARGS = {
    'var': z,
    'params': params,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
graphviz, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Digraph — a Digraph output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Digraph 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
preprocessCatFace Ran
ran on a synthesized input
AlexiaJM/MaximumMarginGANs/Code/preprocess_cat_dataset.py
code served (permissive licence) · get_code("7376fdf98a6f6485")
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 3, dtype family int, shape (40, 39, 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 cv2
import numpy as np
import math

# Create a small test image (cat face simulation)
# Image shape needs to be (height, width, channels) for cv2
image = np.ones((100, 120, 3), dtype=np.uint8) * 128

# Create coords list with 5 points: [leftEyeX, leftEyeY, rightEyeX, rightEyeY, mouthX, ...]
# The function expects at least coords[0:5] and uses coords[6] and coords[16]
# So we need at least 17 elements
coords = [
    30.0, 40.0,      # leftEyeX, leftEyeY (index 0, 1)
    80.0, 45.0,      # rightEyeX, rightEyeY (index 2, 3)
    55.0,            # mouthX (index 4)
    55.0,            # placeholder (index 5)
    75.0, 70.0,      # coords[6], coords[7] - used for width calculation (index 6, 7)
    0.0, 0.0,        # placeholders (index 8, 9)
    0.0, 0.0,        # placeholders (index 10, 11)
    0.0, 0.0,        # placeholders (index 12, 13)
    0.0, 0.0,        # placeholders (index 14, 15)
    35.0, 70.0,      # coords[16], coords[17] - used for width calculation (index 16, 17)
]

ARGS = {
    "coords": coords,
    "image": image,
}
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 ndarray, ndim 3, dtype family int, shape (40, 39, 3) — shape (40, 39, 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
rotateCoords Ran
ran on a synthesized input
AlexiaJM/MaximumMarginGANs/Code/preprocess_cat_dataset.py
code served (permissive licence) · get_code("cf539e0bbc356efb")
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 math

def rotateCoords(coords, center, angleRadians):
    angleRadians = -angleRadians
    xs, ys = (coords[::2], coords[1::2])
    newCoords = []
    n = min(len(xs), len(ys))
    i = 0
    centerX = center[0]
    centerY = center[1]
    cosAngle = math.cos(angleRadians)
    sinAngle = math.sin(angleRadians)
    while i < n:
        xOffset = xs[i] - centerX
        yOffset = ys[i] - centerY
        newX = xOffset * cosAngle - yOffset * sinAngle + centerX
        newY = xOffset * sinAngle + yOffset * cosAngle + centerY
        newCoords += [newX, newY]
        i += 1
    return newCoords

# Setup code
coords = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
center = [2.5, 3.5]
angleRadians = math.pi / 4

ARGS = {
    "coords": coords,
    "center": center,
    "angleRadians": angleRadians
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — 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
strToBool Ran
ran, violated the contract we drafted
AlexiaJM/MaximumMarginGANs/Code/GAN.py
pointer only (licence: MIT); the stored copy get_code serves, from AlexiaJM/RelativisticGAN, is pointer only (licence: NONE) · get_code("9617b12aa6ac6bbe")
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 AlexiaJM/RelativisticGAN, 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.

calculate_activation_statistics Not yet run
unverified (harvested, no recorded run)
AlexiaJM/MaximumMarginGANs/Code/fid.py
code served (permissive licence) · get_code("6917ffcb1214d74f")
How it ran

no invocation recorded.

get_activations Not yet run
unverified (harvested, no recorded run)
AlexiaJM/MaximumMarginGANs/Code/fid.py
code served (permissive licence) · get_code("e69fcd6206886931")
How it ran

no invocation recorded.

register_vis_hooks Not yet run
unverified (harvested, no recorded run)
AlexiaJM/MaximumMarginGANs/Code/pytorch_visualize.py
code served (permissive licence) · get_code("c3ee865ac3297b5a")
How it ran

no invocation recorded.

save_visualization Not yet run
unverified (harvested, no recorded run)
AlexiaJM/MaximumMarginGANs/Code/pytorch_visualize.py
code served (permissive licence) · get_code("17dcbb4211f84f3f")
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, 6 are also present in other papers whose code we hold (5 with at least one paper dated earlier, 0 the same month, 6 later) and 4 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
calculate_frechet_distance 15 other papers
6 dated earlier, 9 later
1406.2661 (2014-06)
Generative Adversarial Networks
1703.10593 (2017-03)
Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
1706.08500 (2017-06)
GANs Trained by a Two Time-Scale Update Rule Converge to a Local Nash Equilibrium
and 12 more not named here
calculate_activation_statistics 12 other papers
6 dated earlier, 6 later
1406.2661 (2014-06)
Generative Adversarial Networks
1703.10593 (2017-03)
Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
1710.10196 (2017-10)
Progressive Growing of GANs for Improved Quality, Stability, and Variation
and 9 more not named here
get_activations 9 other papers
5 dated earlier, 4 later
1703.10593 (2017-03)
Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks
1710.10196 (2017-10)
Progressive Growing of GANs for Improved Quality, Stability, and Variation
1802.10551 (2018-02)
A Variational Inequality Perspective on Generative Adversarial Networks
and 6 more not named here
make_dot 2 other papers
1 dated earlier, 1 later
1710.10903 (2017-10)
Graph Attention Networks
2109.14285 (2021-09)
Be Confident! Towards Trustworthy Graph Neural Networks via Confidence Calibration
strToBool 2 other papers
1 dated earlier, 1 later
1807.00734 (2018-07)
The relativistic discriminator: a key element missing from standard GAN
2002.01136 (2020-02)
On Positive-Unlabeled Classification in GAN
calculate_frechet_distance 1 other paper
1 later
2002.01136 (2020-02)
On Positive-Unlabeled Classification in GAN

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

A popular heuristic for improved performance in Generative adversarial networks (GANs) is to use some form of gradient penalty on the discriminator. This gradient penalty was originally motivated by a Wasserstein distance formulation. However, the use of gradient penalty in other GAN formulations is not well motivated. We present a unifying framework of expected margin maximization and show that a wide range of gradient-penalized GANs (e.g., Wasserstein, Standard, Least-Squares, and Hinge GANs) can be derived from this framework. Our results imply that employing gradient penalties induces a large-margin classifier (thus, a large-margin discriminator in GANs). We describe how expected margin maximization helps reduce vanishing gradients at fake (generated) samples, a known problem in GANs. From this framework, we derive a new $L^\infty$ gradient norm penalty with Hinge loss which generally produces equally good (or better) generated output in GANs than $L^2$-norm penalties (based on the Fréchet Inception Distance).

For agents

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

get_harvested_code_for_paper("1910.06922")
get_code_for_paper("1910.06922")
have("1910.06922")

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

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

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

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

Connect an agent — have() is free.