| Actor |
Ran ran on a synthesized input |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("02d8b297accf97de") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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
INIT_ARGS = {
'state_dim': 4,
'action_dim': 3,
'max_action': 2.0,
'layer_sizes': [4, 8, 8]
}
ARGS = {
'x': torch.randn(2, 4)
}
if __name__ == '__main__':
from collections import OrderedDict
import torch.nn.functional as F
class Actor(nn.Module):
def __init__(self, state_dim, action_dim, max_action, layer_sizes=None):
super(Actor, self).__init__()
if layer_sizes is None:
layer_sizes = [state_dim, 64, 64]
self.nonlinearity = F.relu
self.num_layers = len(layer_sizes)
for i in range(1, self.num_layers):
self.add_module('layer{0}'.format(i), nn.Linear(layer_sizes[i - 1], layer_sizes[i]))
self.a_layer = nn.Linear(layer_sizes[-1], action_dim)
self.max_action = max_action
def forward(self, x, params=None):
if params is None:
params = OrderedDict(self.named_parameters())
output = x
output_list = []
for i in range(1, self.num_layers):
output = F.linear(output, weight=params['layer{0}.weight'.format(i)], bias=params['layer{0}.bias'.format(i)])
output = self.nonlinearity(output, inplace=True)
output_list.append(output)
obs_embedding = output_list[0]
policy_embedding = output_list[1]
output = F.linear(output, weight=params['a_layer.weight'], bias=params['a_layer.bias'])
output = self.max_action * torch.tanh(output)
return (output, obs_embedding, policy_embedding)
actor = Actor(**INIT_ARGS)
result = actor(**ARGS)
print("Output shape:", result[0].shape)
print("Obs embedding shape:", result[1].shape)
print("Policy embedding shape:", result[2].shape)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| CLUB |
Ran ran on a synthesized input |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("93f26c6f16a8c0ae") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 1, dtype family float, shape (2,) 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
class CLUB(nn.Module):
"""
This class provides the CLUB estimation to I(X,Y)
Method:
forward() : provides the estimation with input samples
loglikeli() : provides the log-likelihood of the approximation q(Y|X) with input samples
Arguments:
x_dim, y_dim : the dimensions of samples from X, Y respectively
hidden_size : the dimension of the hidden layer of the approximation network q(Y|X)
x_samples, y_samples : samples from X and Y, having shape [sample_size, x_dim/y_dim]
"""
def __init__(self, x_dim, y_dim, hidden_size):
super(CLUB, self).__init__()
self.p_mu = nn.Sequential(nn.Linear(x_dim, hidden_size // 2), nn.ReLU(inplace=True), nn.Linear(hidden_size // 2, y_dim))
self.p_logvar = nn.Sequential(nn.Linear(x_dim, hidden_size // 2), nn.ReLU(inplace=True), nn.Linear(hidden_size // 2, y_dim), nn.Tanh())
def get_mu_logvar(self, x_samples):
mu = self.p_mu(x_samples)
logvar = self.p_logvar(x_samples)
return (mu, logvar)
def forward(self, x_samples, y_samples):
mu, logvar = self.get_mu_logvar(x_samples)
positive = -(mu - y_samples) ** 2 / 2.0 / logvar.exp()
prediction_1 = mu.unsqueeze(1)
y_samples_1 = y_samples.unsqueeze(0)
negative = -((y_samples_1 - prediction_1) ** 2).mean(dim=1) / 2.0 / logvar.exp()
return positive.sum(dim=-1) - negative.sum(dim=-1)
def loglikeli(self, x_samples, y_samples):
mu, logvar = self.get_mu_logvar(x_samples)
return (-(mu - y_samples) ** 2 / logvar.exp() - logvar).sum(dim=1).mean(dim=0)
def learning_loss(self, x_samples, y_samples):
return -self.loglikeli(x_samples, y_samples)
INIT_ARGS = {
'x_dim': 4,
'y_dim': 3,
'hidden_size': 8,
}
ARGS = {
'x_samples': torch.randn(2, 4),
'y_samples': torch.randn(2, 3),
}
if __name__ == '__main__':
club = CLUB(**INIT_ARGS)
output = club(**ARGS)
print("Forward output shape:", output.shape)
print("Forward output:", output)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- 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 1, dtype family float, shape (2,) — shape (2,) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| Critic |
Ran ran on a synthesized input |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("0b5742fd1596a2a9") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float, shape (2, 1) 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
import torch.nn.functional as F
class Critic(nn.Module):
def __init__(self, state_dim, action_dim):
super(Critic, self).__init__()
self.l1 = nn.Linear(state_dim + action_dim, 64)
self.l2 = nn.Linear(64, 64)
self.l3 = nn.Linear(64, 1)
def forward(self, x, u):
xu = torch.cat([x, u], 1)
x = F.relu(self.l1(xu), inplace=True)
x = F.relu(self.l2(x), inplace=True)
x = self.l3(x)
return x
INIT_ARGS = {
'state_dim': 4,
'action_dim': 3,
}
ARGS = {
'x': torch.randn(2, 4),
'u': torch.randn(2, 3),
}
if __name__ == '__main__':
critic = Critic(**INIT_ARGS)
output = critic(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Output: {output}")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- 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 2, dtype family float, shape (2, 1) — shape (2, 1) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| NEW_MINE |
Ran ran on a synthesized input |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("fe832e6e436cb7d8") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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
import torch.nn.functional as F
import math
def fenchel_dual_loss(l, m, measure=None):
"""Computes the f-divergence distance between positive and negative joint distributions.
Note that vectors should be sent as 1x1.
Divergences supported are Jensen-Shannon `JSD`, `GAN` (equivalent to JSD),
Squared Hellinger `H2`, Chi-squeared `X2`, `KL`, and reverse KL `RKL`.
Args:
l: Local feature map.
m: Multiple globals feature map.
measure: f-divergence measure.
Returns:
torch.Tensor: Loss.
"""
N, units = l.size()
u = torch.mm(m, l.t())
mask = torch.eye(N).to(l.device)
n_mask = 1 - mask
E_pos = get_positive_expectation(u, measure, average=False)
E_neg = get_negative_expectation(u, measure, average=False)
MI = (E_pos * mask).sum(1)
E_pos_term = (E_pos * mask).sum(1)
E_neg_term = (E_neg * n_mask).sum(1) / (N - 1)
loss = E_neg_term - E_pos_term
return (loss, MI)
def get_negative_expectation(q_samples, measure, average=True):
log_2 = math.log(2.0)
if measure == 'GAN':
Eq = F.softplus(-q_samples) + q_samples
elif measure == 'JSD':
Eq = F.softplus(-q_samples) + q_samples - log_2
elif measure == 'X2':
Eq = -0.5 * (torch.sqrt(q_samples ** 2) + 1.0) ** 2
elif measure == 'KL':
q_samples = torch.clamp(q_samples, -1000000.0, 9.5)
Eq = torch.exp(q_samples - 1.0)
elif measure == 'RKL':
Eq = q_samples - 1.0
elif measure == 'H2':
Eq = torch.exp(q_samples) - 1.0
elif measure == 'W1':
Eq = q_samples
else:
assert 1 == 2
if average:
return Eq.mean()
else:
return Eq
def get_positive_expectation(p_samples, measure, average=True):
log_2 = math.log(2.0)
if measure == 'GAN':
Ep = -F.softplus(-p_samples)
elif measure == 'JSD':
Ep = log_2 - F.softplus(-p_samples)
elif measure == 'X2':
Ep = p_samples ** 2
elif measure == 'KL':
Ep = p_samples
elif measure == 'RKL':
Ep = -torch.exp(-p_samples)
elif measure == 'DV':
Ep = p_samples
elif measure == 'H2':
Ep = 1.0 - torch.exp(-p_samples)
elif measure == 'W1':
Ep = p_samples
else:
assert 1 == 2
if average:
return Ep.mean()
else:
return Ep
class NEW_MINE(nn.Module):
def __init__(self, state_size, com_a_size, measure='JSD'):
super(NEW_MINE, self).__init__()
self.measure = measure
self.com_a_size = com_a_size
self.state_size = state_size
self.nonlinearity = F.leaky_relu
self.l1 = nn.Linear(self.state_size, 32)
self.l2 = nn.Linear(self.com_a_size, 32)
def forward(self, state, joint_action, params=None):
em_1 = self.nonlinearity(self.l1(state), inplace=True)
em_2 = self.nonlinearity(self.l2(joint_action), inplace=True)
two_agent_embedding = [em_1, em_2]
loss, MI = fenchel_dual_loss(two_agent_embedding[0], two_agent_embedding[1], measure=self.measure)
return (loss, MI)
INIT_ARGS = {
'state_size': 5,
'com_a_size': 7,
'measure': 'JSD'
}
ARGS = {
'state': torch.randn(3, 5),
'joint_action': torch.randn(3, 7),
'params': None
}
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- torch — 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| OUNoise |
Ran ran on a synthesized input |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("5a6b141fd404c7c4") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned ndarray, ndim 1, dtype family float, shape (4,) 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 numpy as np
class OUNoise:
def __init__(self, action_dimension, scale=0.1, mu=0, theta=0.15, sigma=0.2):
self.action_dimension = action_dimension
self.scale = scale
self.mu = mu
self.theta = theta
self.sigma = sigma
self.state = np.ones(self.action_dimension) * self.mu
self.reset()
def reset(self):
self.state = np.ones(self.action_dimension) * self.mu
def noise(self):
x = self.state
dx = self.theta * (self.mu - x) + self.sigma * np.random.randn(len(x))
self.state = x + dx
return self.state * self.scale
INIT_ARGS = {
'action_dimension': 4,
'scale': 0.1,
'mu': 0,
'theta': 0.15,
'sigma': 0.2
}
ARGS = {}
METHOD = 'noise'
ou_noise = OUNoise(**INIT_ARGS)
result = ou_noise.noise()
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 1, dtype family float, shape (4,) — shape (4,) 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| fenchel_dual_loss |
Ran ran; our contract draft was wrong, not the code |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("dc127827c3f6691e") 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 tuple, ndim 2, 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 torch
import math
torch.manual_seed(0)
# Create small tensors for the function
# l: Local feature map - shape (N, units)
# m: Multiple globals feature map - shape (units, N) or similar
# The function does: u = torch.mm(m, l.t())
# So if l is (N, units), l.t() is (units, N)
# m should be (N, units) to get u as (N, N)
N = 2
units = 4
l = torch.randn(N, units)
m = torch.randn(N, units)
measure = 'JSD'
ARGS = {
'l': l,
'm': m,
'measure': measure
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type tuple, ndim 2, dtype family float — a tuple 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
|
| get_negative_expectation |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("640aa7bb79c50862") 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 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 math
torch.manual_seed(0)
# Create a small tensor for q_samples
q_samples = torch.randn(2, 4)
# Test with different measures
measure = 'GAN'
# average can be True or False
average = True
ARGS = {
'q_samples': q_samples,
'measure': measure,
'average': average
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- 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
|
| get_positive_expectation |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("0edef8661a209cf5") 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 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 math
torch.manual_seed(0)
# Create a small tensor of positive and negative values for p_samples
p_samples = torch.randn(2, 4)
# Test with different measures
measures = ['GAN', 'JSD', 'X2', 'KL', 'RKL', 'DV', 'H2', 'W1']
# Create ARGS for a basic call with one measure
ARGS = {
'p_samples': p_samples,
'measure': 'GAN',
'average': True
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- 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
|
| MA_T_DDPG |
Not yet run unverified (harvested, no recorded run) |
yeshenpy/pmic/algorithms/mpe_new_maxminMADDPG.py code served (permissive licence) · get_code("96cedade50014de1") How it ran |