| AdaptiveThreshold |
Ran ran on a synthesized input · constructed an object; no result was computed |
afofanah/PIMPC-GNN/models/model.py code served (permissive licence) · get_code("281ef5f9a29511e0") How it ranRan 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, AdaptiveThreshold: 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
torch.manual_seed(0)
# Set feature_dim to 8 (must be divisible by num_heads=8)
feature_dim = 8
# Create the model instance
model = nn.Module()
# Create input tensors
batch_size = 2
num_nodes = 3
# combined_features: (batch_size, num_nodes, feature_dim)
combined_features = torch.randn(batch_size, num_nodes, feature_dim, dtype=torch.float32)
# node_features: (batch_size, num_nodes, feature_dim)
node_features = torch.randn(batch_size, num_nodes, feature_dim, dtype=torch.float32)
# Build the AdaptiveThreshold model
adaptive_threshold_model = nn.Module()
# Create ARGS dict with all parameters for AdaptiveThreshold.__init__
ARGS = {
'feature_dim': feature_dim,
}
- 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 AdaptiveThreshold — 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 AdaptiveThreshold 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
|
| ContrastiveLoss |
Ran ran on a synthesized input |
afofanah/PIMPC-GNN/models/model.py code served (permissive licence) · get_code("a6c95628ced93c31") 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 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 torch
import torch.nn as nn
INIT_ARGS = {
'feature_dim': 4,
'temperature': 0.1,
}
ARGS = {
'features': torch.randn(2, 3, 4),
'labels': torch.tensor([[0, 1, 0], [1, 0, 1]]),
'class_counts': torch.tensor([2, 2]),
}
if __name__ == '__main__':
from torch import nn
import torch.nn.functional as F
from typing import Dict, List, Tuple, Optional, Any
class ContrastiveLoss(nn.Module):
def __init__(self, feature_dim: int, temperature: float=0.1):
super(ContrastiveLoss, self).__init__()
self.temperature = temperature
self.projection_head = nn.Sequential(nn.Linear(feature_dim, feature_dim, dtype=torch.float32), nn.LayerNorm(feature_dim), nn.GELU(), nn.Dropout(0.1), nn.Linear(feature_dim, feature_dim // 2, dtype=torch.float32), nn.LayerNorm(feature_dim // 2), nn.GELU(), nn.Linear(feature_dim // 2, feature_dim // 4, dtype=torch.float32))
def forward(self, features: torch.Tensor, labels: torch.Tensor, class_counts: Optional[torch.Tensor]=None) -> torch.Tensor:
batch_size, num_nodes, feature_dim = features.shape
projected_features = self.projection_head(features)
projected_features = F.normalize(projected_features, dim=-1)
features_flat = projected_features.view(-1, projected_features.size(-1))
labels_flat = labels.view(-1)
if class_counts is not None:
valid_mask = (labels_flat >= 0) & (labels_flat < len(class_counts))
if not valid_mask.all():
features_flat = features_flat[valid_mask]
labels_flat = labels_flat[valid_mask]
if len(labels_flat) == 0:
return torch.tensor(0.0, device=features.device)
pos_mask = labels_flat.unsqueeze(0) == labels_flat.unsqueeze(1)
neg_mask = labels_flat.unsqueeze(0) != labels_flat.unsqueeze(1)
sim_matrix = torch.mm(features_flat, features_flat.T) / self.temperature
eye_mask = torch.eye(sim_matrix.size(0), device=sim_matrix.device).bool()
sim_matrix.masked_fill_(eye_mask, -float('inf'))
if class_counts is not None:
class_weights = 1.0 / (class_counts.float() + 1e-08)
class_weights = class_weights / class_weights.sum()
max_label = labels_flat.max().item()
if max_label >= len(class_weights):
pad_size = max_label + 1 - len(class_weights)
class_weights = F.pad(class_weights, (0, pad_size), value=1e-08)
weight_matrix = class_weights[labels_flat].unsqueeze(0) * class_weights[labels_flat].unsqueeze(1)
pos_mask = pos_mask.float() * weight_matrix
exp_sim = torch.exp(sim_matrix)
neg_exp = exp_sim * neg_mask.float()
hard_neg_sum = torch.sum(neg_exp, dim=1, keepdim=True)
pos_exp = exp_sim * pos_mask.float()
pos_sum = torch.sum(pos_exp, dim=1, keepdim=True)
pos_sum = torch.clamp(pos_sum, min=1e-08)
hard_neg_sum = torch.clamp(hard_neg_sum, min=1e-08)
contrastive_loss = -torch.log(pos_sum / (pos_sum + hard_neg_sum + 1e-08))
valid_mask = torch.sum(pos_mask, dim=1) > 0
if valid_mask.sum() > 0:
contrastive_loss = contrastive_loss[valid_mask].mean()
else:
contrastive_loss = torch.tensor(0.0, device=features.device)
return contrastive_loss
model = ContrastiveLoss(**INIT_ARGS)
output = model(**ARGS)
print(f"Output: {output}")
print(f"Output shape: {output.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 Tensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
- 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)
|
| GraphAttentionFusion |
Ran ran on a synthesized input · constructed an object; no result was computed |
afofanah/PIMPC-GNN/models/model.py code served (permissive licence) · get_code("5991001f972de41c") How it ranRan 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, GraphAttentionFusion: 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
torch.manual_seed(0)
# Define the arguments for GraphAttentionFusion
ARGS = {
"input_dims": [4, 5, 6], # Three feature types with different input dimensions
"output_dim": 8, # Output dimension for projection
"num_heads": 2 # Number of attention heads (must divide output_dim)
}
- 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 GraphAttentionFusion — 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 GraphAttentionFusion 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
|
| KuramotoOscillator |
Ran ran on a synthesized input · constructed an object; no result was computed |
afofanah/PIMPC-GNN/models/model.py code served (permissive licence) · get_code("5fc16f8ff965adce") How it ranRan 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, KuramotoOscillator: 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)
class KuramotoOscillator(nn.Module):
def __init__(self, feature_dim: int, num_steps: int=60):
super(KuramotoOscillator, self).__init__()
self.feature_dim = feature_dim
self.num_steps = num_steps
self.frequency_network = nn.Sequential(nn.Linear(feature_dim, feature_dim, dtype=torch.float32), nn.LayerNorm(feature_dim), nn.Tanh(), nn.Linear(feature_dim, feature_dim // 2, dtype=torch.float32), nn.Tanh(), nn.Linear(feature_dim // 2, 1, dtype=torch.float32))
self.coupling_network = nn.Sequential(nn.Linear(feature_dim, feature_dim // 2, dtype=torch.float32), nn.GELU(), nn.Linear(feature_dim // 2, 1, dtype=torch.float32), nn.Sigmoid())
self.sync_analyzer = nn.Sequential(nn.Linear(feature_dim + 4, feature_dim, dtype=torch.float32), nn.LayerNorm(feature_dim), nn.GELU(), nn.Dropout(0.1), nn.Linear(feature_dim, feature_dim // 2, dtype=torch.float32), nn.GELU(), nn.Linear(feature_dim // 2, 1, dtype=torch.float32), nn.Sigmoid())
self.global_coupling = nn.Parameter(torch.tensor(0.5, dtype=torch.float32))
def enhanced_kuramoto_dynamics(self, node_features: torch.Tensor, adjacency_matrix: torch.Tensor):
batch_size, num_nodes, feature_dim = node_features.shape
natural_frequencies = self.frequency_network(node_features).squeeze(-1)
local_coupling = self.coupling_network(node_features).squeeze(-1)
global_coupling = torch.clamp(self.global_coupling, 0.1, 2.0)
phase_init = torch.atan2(torch.sum(node_features * torch.sin(torch.arange(feature_dim, device=node_features.device).float()), dim=-1), torch.sum(node_features * torch.cos(torch.arange(feature_dim, device=node_features.device).float()), dim=-1))
if phase_init.dim() == 3:
phases = phase_init.squeeze(0)
elif phase_init.dim() == 2:
phases = phase_init
else:
phases = phase_init.view(batch_size, num_nodes)
sync_trajectory = []
dt = 0.01
for step in range(self.num_steps):
phase_cos = torch.cos(phases).unsqueeze(-1)
phase_sin = torch.sin(phases).unsqueeze(-1)
neighbor_cos = torch.bmm(adjacency_matrix, phase_cos).squeeze(-1)
neighbor_sin = torch.bmm(adjacency_matrix, phase_sin).squeeze(-1)
coupling_effect = torch.atan2(neighbor_sin, neighbor_cos + 1e-08) - phases
coupling_strength = local_coupling * global_coupling
phase_derivative = natural_frequencies + coupling_strength * torch.sin(coupling_effect)
phases = phases + dt * phase_derivative
phases = phases % (2 * math.pi)
if step % 10 == 0:
complex_phases = torch.complex(torch.cos(phases), torch.sin(phases))
order_param = torch.abs(torch.mean(complex_phases, dim=1))
sync_trajectory.append(order_param)
return (phases, natural_frequencies, local_coupling)
def forward(self, node_features: torch.Tensor, adjacency_matrix: torch.Tensor):
batch_size, num_nodes, feature_dim = node_features.shape
phases, frequencies, coupling = self.enhanced_kuramoto_dynamics(node_features, adjacency_matrix)
phase_features = torch.stack([torch.cos(phases), torch.sin(phases), torch.cos(2 * phases), torch.sin(2 * phases)], dim=-1)
sync_input = torch.cat([node_features, phase_features], dim=-1)
desync_scores = self.sync_analyzer(sync_input).squeeze(-1)
complex_phases = torch.complex(torch.cos(phases), torch.sin(phases))
order_parameter = torch.abs(torch.mean(complex_phases, dim=1))
phase_std = torch.std(phases, dim=1)
return {'desynchronization_scores': desync_scores, 'order_parameter': order_parameter, 'phases': phases, 'frequencies': frequencies, 'coupling_strength': coupling, 'sync_features': sync_input, 'phase_coherence': 1.0 / (1.0 + phase_std)}
feature_dim = 4
num_steps = 10
model = KuramotoOscillator(feature_dim=feature_dim, num_steps=num_steps)
batch_size = 2
num_nodes = 3
node_features = torch.randn(batch_size, num_nodes, feature_dim, dtype=torch.float32)
adjacency_matrix = torch.randn(batch_size, num_nodes, num_nodes, dtype=torch.float32)
ARGS = {
'feature_dim': feature_dim,
'num_steps': num_steps
}
- 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 KuramotoOscillator — 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 KuramotoOscillator 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
|
| SpectralEmbedding |
Ran ran on a synthesized input · constructed an object; no result was computed |
afofanah/PIMPC-GNN/models/model.py code served (permissive licence) · get_code("17ba07f05030e9e7") How it ranRan 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, SpectralEmbedding: 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
torch.manual_seed(0)
# Build minimal arguments for SpectralEmbedding
ARGS = {
"feature_dim": 8,
"num_eigen_vectors": 4,
}
- 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 SpectralEmbedding — 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 SpectralEmbedding 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
|
| Themodynamic |
Ran ran on a synthesized input · constructed an object; no result was computed |
afofanah/PIMPC-GNN/models/model.py code served (permissive licence) · get_code("97bbfc272543e4b2") How it ranRan 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, Themodynamic: 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 torch.nn.functional as F
torch.manual_seed(0)
class Themodynamic(nn.Module):
def __init__(self, feature_dim: int, num_diffusion_steps: int=30):
super(Themodynamic, self).__init__()
self.feature_dim = feature_dim
self.num_diffusion_steps = num_diffusion_steps
self.thermal_conductivity = nn.Parameter(torch.tensor(0.15, dtype=torch.float32))
self.heat_capacity = nn.Parameter(torch.tensor(1.0, dtype=torch.float32))
self.heat_source_network = nn.Sequential(nn.Linear(feature_dim, feature_dim, dtype=torch.float32), nn.LayerNorm(feature_dim), nn.GELU(), nn.Dropout(0.1), nn.Linear(feature_dim, feature_dim // 2, dtype=torch.float32), nn.GELU(), nn.Linear(feature_dim // 2, 1, dtype=torch.float32), nn.Softplus())
self.anomaly_detector = nn.Sequential(nn.Linear(feature_dim * 2, feature_dim, dtype=torch.float32), nn.LayerNorm(feature_dim), nn.GELU(), nn.Dropout(0.15), nn.Linear(feature_dim, feature_dim // 2, dtype=torch.float32), nn.GELU(), nn.Linear(feature_dim // 2, 1, dtype=torch.float32), nn.Sigmoid())
def compute_enhanced_heat_diffusion(self, initial_heat: torch.Tensor, laplacian: torch.Tensor, dt: float=0.015) -> torch.Tensor:
batch_size, num_nodes, feature_dim = initial_heat.shape
laplacian_nodes = laplacian.shape[-1]
if num_nodes != laplacian_nodes:
if num_nodes < laplacian_nodes:
laplacian = laplacian[:, :num_nodes, :num_nodes]
else:
pad_size = num_nodes - laplacian_nodes
laplacian = F.pad(laplacian, (0, pad_size, 0, pad_size), mode='constant', value=0)
current_heat = initial_heat.clone()
thermal_conductivity = torch.clamp(self.thermal_conductivity, 1e-06, 0.5)
heat_capacity = torch.clamp(self.heat_capacity, 0.1, 2.0)
heat_trajectory = []
for step in range(self.num_diffusion_steps):
heat_gradient = torch.bmm(laplacian.expand(batch_size, -1, -1), current_heat)
heat_gradient = torch.clamp(heat_gradient, -5.0, 5.0)
gradient_norm = torch.norm(heat_gradient, dim=-1, keepdim=True)
adaptive_dt = dt / (1 + 0.1 * gradient_norm)
heat_change = adaptive_dt * thermal_conductivity * heat_gradient / heat_capacity
heat_change = torch.clamp(heat_change, -0.5, 0.5)
current_heat = current_heat + heat_change
current_heat = torch.clamp(current_heat, -2.0, 2.0)
if step % 5 == 0:
heat_trajectory.append(current_heat.clone())
if torch.isnan(current_heat).any():
current_heat = initial_heat.clone()
break
return (current_heat, heat_trajectory)
def forward(self, node_features: torch.Tensor, adjacency_matrix: torch.Tensor) -> dict:
batch_size, num_nodes, feature_dim = node_features.shape
degree_matrix = torch.diag_embed(torch.sum(adjacency_matrix, dim=-1) + 1)
laplacian = degree_matrix - adjacency_matrix
heat_sources = self.heat_source_network(node_features)
initial_heat = node_features * heat_sources
diffused_features, trajectory = self.compute_enhanced_heat_diffusion(initial_heat, laplacian)
anomaly_input = torch.cat([node_features, diffused_features], dim=-1)
anomaly_scores = self.anomaly_detector(anomaly_input).squeeze(-1)
return {'anomaly_scores': anomaly_scores, 'diffusion_features': diffused_features, 'heat_sources': heat_sources.squeeze(-1), 'heat_trajectory': trajectory}
feature_dim = 4
num_diffusion_steps = 10
batch_size = 2
num_nodes = 3
node_features = torch.randn(batch_size, num_nodes, feature_dim, dtype=torch.float32)
adjacency_matrix = torch.randn(batch_size, num_nodes, num_nodes, dtype=torch.float32)
ARGS = {
'feature_dim': feature_dim,
'num_diffusion_steps': num_diffusion_steps
}
- 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 Themodynamic — 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 Themodynamic 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
|
| PIMPC_GNN |
Not yet run unverified (harvested, no recorded run) |
afofanah/PIMPC-GNN/models/model.py code served (permissive licence) · get_code("5a583b0b20412a5d") How it ran |