| flatten_jacobian |
Ran ran, honoured the contract we drafted |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("9c77ed5f1b2a5cb5") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ArrayImpl, ndim 2, dtype family float, shape (2, 27) 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 jax
import jax.numpy as jnp
from jax import jacrev, vmap
from jax.tree_util import tree_flatten, tree_map
# Create a simple function to compute jacobians from
def simple_fn(x):
"""A simple function that returns a pytree of jacobians"""
# Returns a dict of arrays (simulating a jacobian pytree structure)
return {
'layer1': jnp.array([[1.0, 2.0], [3.0, 4.0]]),
'layer2': jnp.array([[5.0, 6.0, 7.0], [8.0, 9.0, 10.0]])
}
# Create a jacobian pytree by calling the function
# The jacobian pytree should be a nested structure of arrays
# where each array has a batch dimension that can be vmapped over
J = {
'layer1': jnp.ones((2, 4, 3)), # batch=2, output_dim=4, input_dim=3
'layer2': jnp.ones((2, 5, 3)), # batch=2, output_dim=5, input_dim=3
}
ARGS = {
'J': J
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ArrayImpl, ndim 2, dtype family float, shape (2, 27) — shape (2, 27) 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
|
| get_covariance_fn |
Ran ran; our contract draft was wrong, not the code |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("57f0c39a946e2741") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 jax
import jax.numpy as jnp
import numpy as np
from jax import jacrev, jit, vmap
def flatten_jacobian(jac):
"""Helper to flatten jacobian for the function"""
return jnp.reshape(jac, (jac.shape[0], -1))
# Define a simple model function that takes (params, state, x) and returns logits
def simple_fn(params, state, x):
"""
A simple neural network function.
Takes params (dict), state (dict), and input x.
Returns logits of shape matching the batch size.
"""
# params is a dict with 'w' key
# x has shape (batch_size, input_dim)
# Returns shape (batch_size, output_dim)
w = params['w']
return jnp.dot(x, w)
# Create small test data
batch_size = 2
input_dim = 4
output_dim = 3
attr_dim = 3
# Initialize parameters as a dict
params = {
'w': jnp.ones((input_dim, output_dim))
}
# Initialize state as a dict
state = {
'bn_mean': jnp.zeros(output_dim),
'bn_var': jnp.ones(output_dim)
}
# Create input tensors
X = jnp.ones((batch_size, input_dim))
Y = jnp.ones((batch_size, output_dim))
Z = jnp.ones((batch_size, attr_dim))
ARGS = {
'fn': simple_fn,
'params': params,
'state': state
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax, numpy — 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
|
| get_covariance_fn |
Ran ran; our contract draft was wrong, not the code |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("1a3779fa0f3eac77") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 jax
import jax.numpy as jnp
import numpy as np
# Define a simple function that takes params, state, and x and returns logits
def simple_fn(params, state, x):
"""
A simple neural network function that takes params, state, x
and returns logits. The function should work with vmap.
params: pytree of parameters
state: state dict
x: input array
Returns logits of shape matching the expected output
"""
# Simple linear transformation: logits = x @ W + b
W = params['W'] # shape (4, 3)
b = params['b'] # shape (3,)
logits = jnp.dot(x, W) + b
return logits
# Create params as a pytree (dict of arrays)
params = {
'W': jnp.array(np.random.randn(4, 3), dtype=jnp.float32),
'b': jnp.array(np.random.randn(3), dtype=jnp.float32)
}
# Create state dict
state = {
'batch_norm_mean': jnp.array([0.0, 0.0, 0.0], dtype=jnp.float32),
'batch_norm_var': jnp.array([1.0, 1.0, 1.0], dtype=jnp.float32)
}
# Create small input tensors
# X: batch of inputs, shape (2, 4) - 2 samples, 4 features
X = jnp.array(np.random.randn(2, 4), dtype=jnp.float32)
# Y: batch of targets, shape (2, 3) - 2 samples, 3 output dims
Y = jnp.array(np.random.randn(2, 3), dtype=jnp.float32)
# Z: batch of attributes, shape (2, 3) - 2 samples, 3 attributes
Z = jnp.array(np.random.randn(2, 3), dtype=jnp.float32)
ARGS = {
'fn': simple_fn,
'params': params,
'state': state
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax, numpy — 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
|
| get_fairness_score_fn |
Ran ran; our contract draft was wrong, not the code |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("747ee8ffd596f2a7") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 jax
import jax.numpy as jnp
import numpy as np
from jax import jacrev, jit, vmap
# Define hinge_loss function that's used in the code
def hinge_loss(logits, y):
return jnp.maximum(0, 1 - logits * y)
# Define flatten_jacobian function that's used in the code
def flatten_jacobian(jac):
batch_size = jac.shape[0]
return jac.reshape(batch_size, -1)
# Create a minimal model function that takes (params, state, x) and returns logits
def model_fn(params, state, x):
# Simple linear model: output shape (batch_size, 1) for binary classification
# x shape: (batch_size, 4)
# params is a dict with 'w' and 'b'
logits = jnp.dot(x, params['w']) + params['b']
return logits
# Create params - a dict with weight matrix and bias
params = {
'w': jnp.array([0.1, 0.2, 0.3, 0.4]), # shape (4,) to match input dim
'b': jnp.array(0.05) # scalar bias
}
# Create state - can be empty dict or minimal state
state = {}
# Create sample data
X = jnp.array([
[1.0, 2.0, 3.0, 4.0],
[2.0, 3.0, 4.0, 5.0]
], dtype=jnp.float32) # shape (2, 4)
Y = jnp.array([1.0, -1.0]) # shape (2,) - binary labels
Z = jnp.array([0.5, 0.7]) # shape (2,) - attributes for fairness
# Define ARGS dict with all parameters for get_fairness_score_fn
ARGS = {
'fn': model_fn,
'params': params,
'state': state,
'score_type': 'grad_norm'
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax, numpy — 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
|
| get_fairness_score_fn |
Ran ran; our contract draft was wrong, not the code |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("1b73c1d15c0dec20") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 jax
import jax.numpy as jnp
import numpy as np
# Set seed for reproducibility
np.random.seed(0)
# Define a minimal model function that takes (params, state, x) and returns logits
def model_fn(params, state, x):
"""
Minimal model function that takes params, state, and input x.
Returns logits for each sample.
"""
# x shape: (batch_size, input_dim)
# params is a dict with 'w' and 'b'
# Simple linear model: logits = x @ w + b
logits = jnp.dot(x, params['w']) + params['b']
return logits
# Create minimal params dict
params = {
'w': jnp.array([[0.1, 0.2], [0.3, 0.4], [0.5, 0.6], [0.7, 0.8]]), # (4, 2)
'b': jnp.array([0.1, 0.2]) # (2,)
}
# Create minimal state dict
state = {
'batch_norm_mean': jnp.array([0.0, 0.0]),
'batch_norm_var': jnp.array([1.0, 1.0])
}
# Create sample data
# X: (batch_size=2, input_dim=4)
X = jnp.array([
[1.0, 2.0, 3.0, 4.0],
[5.0, 6.0, 7.0, 8.0]
])
# Y: (batch_size=2, num_classes=2) - binary labels
Y = jnp.array([
[0, 1],
[1, 0]
])
# Z: (batch_size=2, num_attributes=3) - attributes for covariance
Z = jnp.array([
[0.1, 0.2, 0.3],
[0.4, 0.5, 0.6]
])
# score_type options
score_type = 'covariance'
ARGS = {
'fn': model_fn,
'params': params,
'state': state,
'score_type': score_type
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax, numpy — 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
|
| get_hinge_loss_grad_norm_fn |
Ran ran; our contract draft was wrong, not the code |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("9845cd99b6c24f4a") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 jax
import jax.numpy as jnp
import numpy as np
from jax import jacrev, jit, vmap
# Define hinge_loss function that the code references
def hinge_loss(logits, label):
return jnp.maximum(0, 1 - label * logits)
# Define flatten_jacobian function that the code references
def flatten_jacobian(jacobian_matrix):
# Flatten all dimensions except the first (batch dimension)
batch_size = jacobian_matrix.shape[0]
return jacobian_matrix.reshape(batch_size, -1)
# Create a simple model function that takes (params, state, x) and returns logits
def simple_model(params, state, x):
# params: dict with 'w' key
# state: dict with 'scale' key
# x: input array
# Returns logits for each sample
w = params['w']
scale = state['scale']
# Simple linear transformation: (batch, 4) @ (4, 3) -> (batch, 3)
logits = jnp.dot(x, w) * scale
return logits
# Create params dict with a weight matrix
params = {
'w': jnp.array(np.random.randn(4, 3).astype(np.float32))
}
# Create state dict
state = {
'scale': jnp.array(1.0)
}
# Create model function
fn = simple_model
# Create small sample data
X = jnp.array(np.random.randn(2, 4).astype(np.float32)) # batch=2, features=4
Y = jnp.array(np.array([1.0, -1.0])) # batch=2, binary labels
ARGS = {
'fn': fn,
'params': params,
'state': state
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax, numpy — 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
|
| get_hinge_loss_grad_norm_fn |
Ran ran; our contract draft was wrong, not the code |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("019e8e5917ec430c") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) 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 jax.numpy as jnp
import numpy as np
# Define a simple model function that takes (params, state, x) and returns logits
def simple_model(params, state, x):
"""Simple linear model: output = x @ params"""
# x shape: (batch_size, input_dim)
# params shape: (input_dim, output_dim)
# output shape: (batch_size, output_dim)
return jnp.dot(x, params)
# Create small test data
batch_size = 2
input_dim = 4
output_dim = 3
# Initialize parameters (input_dim x output_dim)
params = jnp.ones((input_dim, output_dim))
# Initialize state (can be empty dict or None-like)
state = {}
# Create sample input X (batch_size x input_dim)
X = jnp.array([
[1.0, 2.0, 3.0, 4.0],
[5.0, 6.0, 7.0, 8.0]
])
# Create sample labels Y (batch_size,) with binary labels
Y = jnp.array([0, 1])
ARGS = {
"fn": simple_model,
"params": params,
"state": state,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax, numpy — 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
|
| hinge_loss |
Ran ran, violated the contract we drafted |
ucsc-real/fairinfl/scores.py code served (permissive licence) · get_code("5c68a51000a1bbee") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned ArrayImpl, 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 jax.numpy as jnp
import numpy as np
# Create small sample data for hinge_loss
# logits: shape (2,) - batch of 2 logit values
# labels: shape (2,) - batch of 2 binary labels (0 or 1)
logits = jnp.array([0.5, -0.3], dtype=jnp.float32)
labels = jnp.array([1, 0], dtype=jnp.int32)
ARGS = {
"logits": logits,
"labels": labels,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ArrayImpl, 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
|