| CosineEnvelope |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("8ac6bce450fc85e3") 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, 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 torch
from torch import nn
import numpy as np
from torch import nn
import numpy as np
import torch
class CosineEnvelope(nn.Module):
def __init__(self, cutoff):
super().__init__()
self.cutoff = cutoff
def forward(self, d):
output = 0.5 * (torch.cos(np.pi * d / self.cutoff) + 1)
exclude = d >= self.cutoff
output[exclude] = 0
return output
INIT_ARGS = {
'cutoff': 5.0
}
ARGS = {
'd': torch.tensor([[0.5, 1.0, 2.5, 4.0], [0.1, 3.0, 5.5, 6.0]], dtype=torch.float32)
}
if __name__ == '__main__':
envelope = CosineEnvelope(**INIT_ARGS)
result = envelope(**ARGS)
print(result)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- numpy, 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, 4) — shape (2, 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)
|
| Dense |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("dc349a5755ad2883") 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, 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 torch
from torch import nn
from functools import partial
from torch.nn.init import constant_, xavier_uniform_
DEFAULT_DROPOUT_RATE = 0.0
zeros_initializer = partial(constant_, val=0.0)
class Dense(nn.Linear):
"""Applies a dense layer with activation: :math:`y = activation(Wx + b)`
Args:
in_features (int): number of input feature
out_features (int): number of output features
bias (bool): If set to False, the layer will not adapt the bias. (default: True)
activation (callable): activation function (default: None)
weight_init (callable): function that takes weight tensor and initializes (default: xavier)
bias_init (callable): function that takes bias tensor and initializes (default: zeros initializer)
"""
def __init__(self, in_features, out_features, bias=True, activation=None, dropout_rate=DEFAULT_DROPOUT_RATE, weight_init=xavier_uniform_, bias_init=zeros_initializer):
self.weight_init = weight_init
self.bias_init = bias_init
super().__init__(in_features, out_features, bias)
self.activation = activation
self.dropout = nn.Dropout(p=dropout_rate)
def reset_parameters(self):
"""
Reinitialize model parameters.
"""
self.weight_init(self.weight)
if self.bias is not None:
self.bias_init(self.bias)
def forward(self, inputs):
"""
Args:
inputs (dict of torch.Tensor): SchNetPack format dictionary of input tensors.
Returns:
torch.Tensor: Output of the dense layer.
"""
self.to(inputs.device)
y = super().forward(inputs)
if hasattr(self, 'dropout'):
y = self.dropout(y)
if self.activation:
y = self.activation(y)
return y
INIT_ARGS = {
'in_features': 4,
'out_features': 3,
'bias': True,
'activation': nn.ReLU(),
'dropout_rate': 0.1,
'weight_init': xavier_uniform_,
'bias_init': zeros_initializer,
}
ARGS = {
'inputs': torch.randn(2, 4),
}
if __name__ == '__main__':
layer = Dense(**INIT_ARGS)
output = layer(**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, 3) — shape (2, 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| DistanceEmbed |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("6af9e88a6c54be01") 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 (6, 12) 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
from torch import nn
import numpy as np
from functools import partial
from torch.nn.init import constant_, xavier_uniform_
from torch import nn
import numpy as np
import torch
from functools import partial
from torch.nn.init import constant_, xavier_uniform_
class CosineEnvelope(nn.Module):
def __init__(self, cutoff):
super().__init__()
self.cutoff = cutoff
def forward(self, d):
output = 0.5 * (torch.cos(np.pi * d / self.cutoff) + 1)
exclude = d >= self.cutoff
output[exclude] = 0
return output
DEFAULT_DROPOUT_RATE = 0.0
class PainnRadialBasis(nn.Module):
def __init__(self, n_rbf, cutoff, learnable_k):
super().__init__()
self.n = torch.arange(1, n_rbf + 1).float()
if learnable_k:
self.n = nn.Parameter(self.n)
self.cutoff = cutoff
def forward(self, dist):
"""
Args:
d (torch.Tensor): tensor of distances
"""
shape_d = dist.unsqueeze(-1)
n = self.n.to(dist.device)
coef = n * np.pi / self.cutoff
device = shape_d.device
denom = torch.where(shape_d == 0, torch.tensor(1.0, device=device), shape_d)
num = torch.where(shape_d == 0, coef, torch.sin(coef * shape_d))
output = torch.where(shape_d >= self.cutoff, torch.tensor(0.0, device=device), num / denom)
return output
zeros_initializer = partial(constant_, val=0.0)
class Dense(nn.Linear):
"""Applies a dense layer with activation: :math:`y = activation(Wx + b)`
Args:
in_features (int): number of input feature
out_features (int): number of output features
bias (bool): If set to False, the layer will not adapt the bias. (default: True)
activation (callable): activation function (default: None)
weight_init (callable): function that takes weight tensor and initializes (default: xavier)
bias_init (callable): function that takes bias tensor and initializes (default: zeros initializer)
"""
def __init__(self, in_features, out_features, bias=True, activation=None, dropout_rate=DEFAULT_DROPOUT_RATE, weight_init=xavier_uniform_, bias_init=zeros_initializer):
self.weight_init = weight_init
self.bias_init = bias_init
super().__init__(in_features, out_features, bias)
self.activation = activation
self.dropout = nn.Dropout(p=dropout_rate)
def reset_parameters(self):
"""
Reinitialize model parameters.
"""
self.weight_init(self.weight)
if self.bias is not None:
self.bias_init(self.bias)
def forward(self, inputs):
"""
Args:
inputs (dict of torch.Tensor): SchNetPack format dictionary of input tensors.
Returns:
torch.Tensor: Output of the dense layer.
"""
self.to(inputs.device)
y = super().forward(inputs)
if hasattr(self, 'dropout'):
y = self.dropout(y)
if self.activation:
y = self.activation(y)
return y
class DistanceEmbed(nn.Module):
def __init__(self, n_rbf, cutoff, feat_dim, learnable_k, dropout):
super().__init__()
rbf = PainnRadialBasis(n_rbf=n_rbf, cutoff=cutoff, learnable_k=learnable_k)
dense = Dense(in_features=n_rbf, out_features=3 * feat_dim, bias=True, dropout_rate=dropout)
self.block = nn.Sequential(rbf, dense)
self.f_cut = CosineEnvelope(cutoff=cutoff)
def forward(self, dist):
rbf_feats = self.block(dist)
envelope = self.f_cut(dist).reshape(-1, 1)
output = rbf_feats * envelope
return output
INIT_ARGS = {
'n_rbf': 8,
'cutoff': 5.0,
'feat_dim': 4,
'learnable_k': False,
'dropout': 0.1,
}
ARGS = {
'dist': torch.tensor([0.5, 1.5, 2.5, 3.5, 4.5, 5.5], dtype=torch.float32),
}
if __name__ == '__main__':
model = DistanceEmbed(**INIT_ARGS)
output = model(**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
- numpy, 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 (6, 12) — shape (6, 12) 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)
|
| EmbeddingBlock |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("952ca748b3f1516e") 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
from torch import nn
class EmbeddingBlock(nn.Module):
def __init__(self, feat_dim):
super().__init__()
self.atom_embed = nn.Embedding(100, feat_dim, padding_idx=0)
self.feat_dim = feat_dim
def forward(self, z_number, **kwargs):
num_atoms = z_number.shape[0]
s_i = self.atom_embed(z_number)
v_i = torch.zeros(num_atoms, self.feat_dim, 3).to(s_i.device)
return (s_i, v_i)
INIT_ARGS = {
'feat_dim': 4
}
ARGS = {
'z_number': torch.tensor([1, 5, 8, 12], dtype=torch.long)
}
if __name__ == '__main__':
model = EmbeddingBlock(**INIT_ARGS)
output = model(**ARGS)
print(f"s_i shape: {output[0].shape}")
print(f"v_i shape: {output[1].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)
|
| InvariantDense |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("7f75d01bd99cc6dd") 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, 12) 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
from torch import nn
import numpy as np
import torch.nn.functional as F
from functools import partial
from torch.nn.init import constant_, xavier_uniform_
DEFAULT_DROPOUT_RATE = 0.0
class LearnableSwish(torch.nn.Module):
def __init__(self, alpha=1.0, beta=1.702):
super().__init__()
self.alpha_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([alpha])) - 1))
self.beta_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([beta])) - 1))
@property
def alpha(self):
return F.softplus(self.alpha_inv)
@property
def beta(self):
return F.softplus(self.beta_inv)
def forward(self, x):
device = x.device
alpha = self.alpha.to(device)
beta = self.beta.to(device)
output = alpha / beta * F.silu(beta * x)
return output
class Swish(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return F.silu(x)
class shifted_softplus(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
return F.softplus(input) - np.log(2.0)
zeros_initializer = partial(constant_, val=0.0)
class Dense(nn.Linear):
def __init__(self, in_features, out_features, bias=True, activation=None, dropout_rate=DEFAULT_DROPOUT_RATE, weight_init=xavier_uniform_, bias_init=zeros_initializer):
self.weight_init = weight_init
self.bias_init = bias_init
super().__init__(in_features, out_features, bias)
self.activation = activation
self.dropout = nn.Dropout(p=dropout_rate)
def reset_parameters(self):
self.weight_init(self.weight)
if self.bias is not None:
self.bias_init(self.bias)
def forward(self, inputs):
self.to(inputs.device)
y = super().forward(inputs)
if hasattr(self, 'dropout'):
y = self.dropout(y)
if self.activation:
y = self.activation(y)
return y
layer_types = {'linear': torch.nn.Linear, 'Tanh': torch.nn.Tanh, 'ReLU': torch.nn.ReLU, 'Dense': Dense, 'shifted_softplus': shifted_softplus, 'sigmoid': torch.nn.Sigmoid, 'Dropout': torch.nn.Dropout, 'LeakyReLU': torch.nn.LeakyReLU, 'ELU': torch.nn.ELU, 'swish': Swish, 'learnable_swish': LearnableSwish, 'softplus': torch.nn.Softplus}
def to_module(activation):
return layer_types[activation]()
class InvariantDense(nn.Module):
def __init__(self, dim, dropout, activation='swish'):
super().__init__()
self.layers = nn.Sequential(Dense(in_features=dim, out_features=dim, bias=True, dropout_rate=dropout, activation=to_module(activation)), Dense(in_features=dim, out_features=3 * dim, bias=True, dropout_rate=dropout))
def forward(self, s_j):
output = self.layers(s_j)
return output
INIT_ARGS = {
'dim': 4,
'dropout': 0.1,
'activation': 'swish'
}
ARGS = {
's_j': torch.randn(2, 4)
}
if __name__ == '__main__':
model = InvariantDense(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: (2, 12)")
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- numpy, 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, 12) — shape (2, 12) 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)
|
| LearnableSwish |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("0d21a7509e419d0b") 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, 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 torch
import torch.nn.functional as F
from torch import nn
class LearnableSwish(torch.nn.Module):
def __init__(self, alpha=1.0, beta=1.702):
super().__init__()
self.alpha_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([alpha])) - 1))
self.beta_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([beta])) - 1))
@property
def alpha(self):
return F.softplus(self.alpha_inv)
@property
def beta(self):
return F.softplus(self.beta_inv)
def forward(self, x):
device = x.device
alpha = self.alpha.to(device)
beta = self.beta.to(device)
output = alpha / beta * F.silu(beta * x)
return output
INIT_ARGS = {
'alpha': 1.0,
'beta': 1.702
}
ARGS = {
'x': torch.randn(2, 4)
}
if __name__ == '__main__':
module = LearnableSwish(**INIT_ARGS)
output = module(**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, 4) — shape (2, 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)
|
| MolFpPool |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("398bfbf43b702ff8") 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 dict. 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 numpy as np
from torch import nn
from torch.nn import LeakyReLU, Linear, ModuleDict, ReLU, Sequential, Softmax
from torch.autograd import grad
from functools import partial
from torch.nn.init import constant_, xavier_uniform_
import torch.nn.functional as F
DEFAULT_DROPOUT_RATE = 0.0
class LearnableSwish(torch.nn.Module):
def __init__(self, alpha=1.0, beta=1.702):
super().__init__()
self.alpha_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([alpha])) - 1))
self.beta_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([beta])) - 1))
@property
def alpha(self):
return F.softplus(self.alpha_inv)
@property
def beta(self):
return F.softplus(self.beta_inv)
def forward(self, x):
device = x.device
alpha = self.alpha.to(device)
beta = self.beta.to(device)
output = alpha / beta * F.silu(beta * x)
return output
class Swish(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return F.silu(x)
def compute_grad(inputs, output, allow_unused=False):
assert inputs.requires_grad
gradspred, = grad(output, inputs, grad_outputs=output.data.new(output.shape).fill_(1), create_graph=True, retain_graph=True, allow_unused=allow_unused)
return gradspred
class shifted_softplus(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
return F.softplus(input) - np.log(2.0)
zeros_initializer = partial(constant_, val=0.0)
class Dense(nn.Linear):
def __init__(self, in_features, out_features, bias=True, activation=None, dropout_rate=DEFAULT_DROPOUT_RATE, weight_init=xavier_uniform_, bias_init=zeros_initializer):
self.weight_init = weight_init
self.bias_init = bias_init
super().__init__(in_features, out_features, bias)
self.activation = activation
self.dropout = nn.Dropout(p=dropout_rate)
def reset_parameters(self):
self.weight_init(self.weight)
if self.bias is not None:
self.bias_init(self.bias)
def forward(self, inputs):
self.to(inputs.device)
y = super().forward(inputs)
if hasattr(self, 'dropout'):
y = self.dropout(y)
if self.activation:
y = self.activation(y)
return y
layer_types = {'linear': torch.nn.Linear, 'Tanh': torch.nn.Tanh, 'ReLU': torch.nn.ReLU, 'Dense': Dense, 'shifted_softplus': shifted_softplus, 'sigmoid': torch.nn.Sigmoid, 'Dropout': torch.nn.Dropout, 'LeakyReLU': torch.nn.LeakyReLU, 'ELU': torch.nn.ELU, 'swish': Swish, 'learnable_swish': LearnableSwish, 'softplus': torch.nn.Softplus}
class MolFpPool(nn.Module):
def __init__(self, feat_dim, mol_fp_act, num_out_layers, out_dim, **kwargs):
super().__init__()
feat_num = [int(feat_dim / num_out_layers ** m) for m in range(num_out_layers)]
mol_fp_layers = [Dense(in_features=feat_num[i], out_features=feat_num[i + 1], activation=layer_types[mol_fp_act]()) for i in range(num_out_layers - 1)]
mol_fp_layers.append(Dense(in_features=feat_num[-1], out_features=out_dim, activation=None))
self.mol_fp_nn = Sequential(*mol_fp_layers)
def forward(self, batch, xyz, atomwise_output, grad_keys, out_keys):
N = batch['num_atoms'].detach().cpu().tolist()
results = {}
for key in out_keys:
batched_feats = atomwise_output['features']
split_feats = torch.split(batched_feats, N)
all_outputs = []
learned_feats = []
for feats in split_feats:
mol_fp = feats.sum(0)
output = self.mol_fp_nn(mol_fp)
all_outputs.append(output)
results[key] = torch.stack(all_outputs)
return results
INIT_ARGS = {
'feat_dim': 16,
'mol_fp_act': 'ReLU',
'num_out_layers': 2,
'out_dim': 5,
}
ARGS = {
'batch': {'num_atoms': torch.tensor([3, 2])},
'xyz': torch.randn(5, 3),
'atomwise_output': {'features': torch.randn(5, 16)},
'grad_keys': [],
'out_keys': ['energy'],
}
if __name__ == '__main__':
model = MolFpPool(**INIT_ARGS)
result = model(**ARGS)
print("Result keys:", result.keys())
print("Result shape:", result['energy'].shape)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
|
| PainnRadialBasis |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("b65822c621376024") 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 (4, 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 torch
from torch import nn
import numpy as np
from torch import nn
import numpy as np
import torch
class PainnRadialBasis(nn.Module):
def __init__(self, n_rbf, cutoff, learnable_k):
super().__init__()
self.n = torch.arange(1, n_rbf + 1).float()
if learnable_k:
self.n = nn.Parameter(self.n)
self.cutoff = cutoff
def forward(self, dist):
"""
Args:
d (torch.Tensor): tensor of distances
"""
shape_d = dist.unsqueeze(-1)
n = self.n.to(dist.device)
coef = n * np.pi / self.cutoff
device = shape_d.device
denom = torch.where(shape_d == 0, torch.tensor(1.0, device=device), shape_d)
num = torch.where(shape_d == 0, coef, torch.sin(coef * shape_d))
output = torch.where(shape_d >= self.cutoff, torch.tensor(0.0, device=device), num / denom)
return output
INIT_ARGS = {
'n_rbf': 4,
'cutoff': 5.0,
'learnable_k': False,
}
ARGS = {
'dist': torch.tensor([0.5, 1.0, 2.0, 3.5]),
}
if __name__ == '__main__':
model = PainnRadialBasis(**INIT_ARGS)
output = model(**ARGS)
print(output)
print(output.shape)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- numpy, 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 (4, 4) — shape (4, 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)
|
| ScaleShift |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("802d844e902371ef") 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, 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 torch
from torch import nn
class ScaleShift(nn.Module):
"""Scale and shift layer for standardization.
.. math::
y = x \\times \\sigma + \\mu
Args:
means (dict): dictionary of mean values
stddevs (dict): dictionary of standard deviations
"""
def __init__(self, means=None, stddevs=None):
super().__init__()
means = means if means is not None else {}
stddevs = stddevs if stddevs is not None else {}
self.means = means
self.stddevs = stddevs
def forward(self, inp, key):
"""Compute layer output.
Args:
inp (torch.Tensor): input data.
key (str): key to look up mean and stddev.
Returns:
torch.Tensor: layer output.
"""
stddev = self.stddevs.get(key, 1.0)
mean = self.means.get(key, 0.0)
out = inp * stddev + mean
return out
INIT_ARGS = {
"means": {"feature_a": 2.5, "feature_b": -1.0},
"stddevs": {"feature_a": 0.5, "feature_b": 2.0}
}
ARGS = {
"inp": torch.randn(2, 4),
"key": "feature_a"
}
- 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, 4) — shape (2, 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)
|
| Swish |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("7f836403bedf830d") 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, 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 torch
import torch.nn.functional as F
class Swish(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return F.silu(x)
INIT_ARGS = {}
ARGS = {
'x': torch.randn(2, 4)
}
if __name__ == '__main__':
model = Swish(**INIT_ARGS)
output = model(**ARGS)
print(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, 4) — shape (2, 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)
|
| add_embedding |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("5cfab56ad64af6fe") 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 dict. 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)
# The function expects:
# - atomwise_out: a dict with a 'features' key containing a tensor
# - all_results: a dict that will be modified to include 'embedding'
# Create a small features tensor (batch_size=2, feature_dim=4)
features_tensor = torch.randn(2, 4)
# Create atomwise_out dict with 'features' key
atomwise_out = {
'features': features_tensor
}
# Create all_results dict (can be empty or have other keys)
all_results = {
'other_key': 'other_value'
}
ARGS = {
'atomwise_out': atomwise_out,
'all_results': all_results
}
- 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 dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
|
| att_readout_probs |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("2eece0db59be49c0") 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 torch
import torch.nn.functional as F
torch.manual_seed(0)
# The function att_readout_probs takes a single parameter 'name'
# which should be a string that is either 'softmax' or 'square'
# Let's test with 'softmax'
ARGS = {
'name': 'softmax'
}
- 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 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
|
| compute_grad |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("2ac65d5ac1bf4b38") 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 2, dtype family float, shape (2, 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 torch
from torch.autograd import grad
torch.manual_seed(0)
# Create a small tensor that requires gradients
inputs = torch.randn(2, 4, requires_grad=True)
# Create a scalar output by reducing a computation graph
# We need output to be a scalar for the grad function to work properly
intermediate = inputs.sum(dim=1) # shape (2,)
output = intermediate.mean() # scalar
# allow_unused parameter
allow_unused = False
ARGS = {
"inputs": inputs,
"output": output,
"allow_unused": allow_unused,
}
- 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 2, dtype family float, shape (2, 4) — shape (2, 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: none by the harness; any seed is in the setup block
|
| gen |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("07fc732b54bba7cd") 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 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 numpy as np
from itertools import repeat
torch.manual_seed(0)
# Create a small source tensor (batch_size=2, feature_dim=4)
src = torch.randn(2, 4)
# Create an index tensor that will be expanded
# This is a 1D tensor with values indicating target positions
index = torch.tensor([0, 1, 0, 2])
# Optional: dim parameter (default -1, which means last dimension)
dim = -1
# Optional: out tensor (if None, will be created in the function)
out = None
# Optional: dim_size (if None, will be inferred from index.max())
dim_size = None
# Optional: fill_value for initializing the output tensor
fill_value = 0
ARGS = {
"src": src,
"index": index,
"dim": dim,
"out": out,
"dim_size": dim_size,
"fill_value": fill_value,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- numpy, 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: none by the harness; any seed is in the setup block
|
| get_offsets |
Ran ran, honoured the contract we drafted |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("18fd70ccb86319a7") 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 Tensor, ndim 2, dtype family float, shape (2, 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 torch
torch.manual_seed(0)
# The function expects:
# 1. batch: a dict with 'nxyz' key (required) and optionally a key parameter
# 2. key: a string to look up in the batch dict
# Construct a batch dict with 'nxyz' tensor and optional offset tensors
batch = {
'nxyz': torch.randn(2, 4), # Small tensor on CPU
'offsets_dense': torch.randn(2, 3), # Dense offset tensor
'offsets_sparse': torch.sparse_coo_tensor(
indices=torch.tensor([[0, 1], [0, 1]]),
values=torch.tensor([1.0, 2.0]),
size=(2, 3)
) # Sparse offset tensor that can be converted to dense
}
key = 'offsets_dense'
ARGS = {
'batch': batch,
'key': key
}
- 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 2, dtype family float, shape (2, 3) — shape (2, 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
|
| get_rij |
Ran ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("2cfb01eec4fba085") 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 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
torch.manual_seed(0)
# Create a batch dictionary with required 'nxyz' key
batch = {
'nxyz': torch.randn(2, 4), # Small tensor on CPU
'offsets': torch.randn(5, 3) # Small offsets tensor
}
# Create xyz coordinates: shape (num_atoms, 3)
xyz = torch.randn(6, 3)
# Create neighbor pairs: shape (num_pairs, 2)
# Each row is [atom_i, atom_j] indices
nbrs = torch.tensor([
[0, 1],
[1, 2],
[2, 3],
[3, 4],
[4, 5]
], dtype=torch.long)
# Create cutoff as a scalar tensor
cutoff = torch.tensor(5.0)
ARGS = {
'xyz': xyz,
'batch': batch,
'nbrs': nbrs,
'cutoff': cutoff
}
- 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 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
|
| make_directed |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("3e1aa28156810aba") 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. 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
torch.manual_seed(0)
# nbr_list is a 2D tensor where each row contains two indices
# The function checks if there are pairs where first > second and pairs where second > first
# to determine if the graph is directed
nbr_list = torch.tensor([
[0, 1],
[2, 1]
], dtype=torch.long)
ARGS = {
"nbr_list": nbr_list
}
- 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 — 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
|
| norm |
Ran ran, honoured the contract we drafted |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("3df02af32c33da5a") 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 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 numpy as np
torch.manual_seed(0)
# The function 'norm' takes a single parameter 'vec'
# It performs: (vec ** 2 + EPS).sum(-1) ** 0.5
# This means:
# - vec is squared element-wise
# - EPS is added
# - sum over the last dimension
# - square root is taken
# So vec should be a tensor with at least 1 dimension
# Create a small tensor with shape (2, 4) - batch of 2, dimension 4
vec = torch.randn(2, 4)
ARGS = {
"vec": vec
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- numpy, 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: none by the harness; any seed is in the setup block
|
| preprocess_r |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("6565f4a40973667d") 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. 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 numpy as np
torch.manual_seed(0)
# Create a small tensor of interatomic vectors
# Shape: (n_nbrs, 3) where n_nbrs=2 (number of neighbors) and 3 is spatial dimension
r_ij = torch.randn(2, 3, dtype=torch.float32)
ARGS = {
"r_ij": r_ij
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- numpy, 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: none by the harness; any seed is in the setup block
|
| scatter_add |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("04e4a832f331db07") 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 Tensor, ndim 2, dtype family float, shape (2, 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 torch
import torch.nn as nn
torch.manual_seed(0)
# Create test tensors
src = torch.randn(2, 4) # Source tensor: batch_size=2, features=4
index = torch.tensor([0, 1, 0, 2]) # Index tensor: 1D, size=4
ARGS = {
"src": src,
"index": index,
"dim": -1,
"out": None,
"dim_size": None,
"fill_value": 0
}
- 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 2, dtype family float, shape (2, 3) — shape (2, 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
|
| shifted_softplus |
Ran ran on a synthesized input |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("42c43fca053545ea") 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, 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
import torch
import torch.nn.functional as F
class shifted_softplus(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
return F.softplus(input) - np.log(2.0)
INIT_ARGS = {}
ARGS = {
'input': torch.randn(2, 4)
}
if __name__ == '__main__':
instance = shifted_softplus(**INIT_ARGS)
output = instance(**ARGS)
print(output)
- Setup block drafted by
- a language model, class construct-then-call prompt, model not recorded
- Imports
- numpy, 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, 4) — shape (2, 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)
|
| to_module |
Ran ran; our contract draft was wrong, not the code |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("a929e9679ef4134f") 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 Swish. 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 numpy as np
from torch import nn
from functools import partial
from torch.nn.init import constant_, xavier_uniform_
import torch.nn.functional as F
torch.manual_seed(0)
DEFAULT_DROPOUT_RATE = 0.0
class LearnableSwish(torch.nn.Module):
def __init__(self, alpha=1.0, beta=1.702):
super().__init__()
self.alpha_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([alpha])) - 1))
self.beta_inv = nn.Parameter(torch.log(torch.exp(torch.Tensor([beta])) - 1))
@property
def alpha(self):
return F.softplus(self.alpha_inv)
@property
def beta(self):
return F.softplus(self.beta_inv)
def forward(self, x):
device = x.device
alpha = self.alpha.to(device)
beta = self.beta.to(device)
output = alpha / beta * F.silu(beta * x)
return output
class Swish(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, x):
return F.silu(x)
class shifted_softplus(torch.nn.Module):
def __init__(self):
super().__init__()
def forward(self, input):
return F.softplus(input) - np.log(2.0)
zeros_initializer = partial(constant_, val=0.0)
class Dense(nn.Linear):
"""Applies a dense layer with activation: :math:`y = activation(Wx + b)`
Args:
in_features (int): number of input feature
out_features (int): number of output features
bias (bool): If set to False, the layer will not adapt the bias. (default: True)
activation (callable): activation function (default: None)
weight_init (callable): function that takes weight tensor and initializes (default: xavier)
bias_init (callable): function that takes bias tensor and initializes (default: zeros initializer)
"""
def __init__(self, in_features, out_features, bias=True, activation=None, dropout_rate=DEFAULT_DROPOUT_RATE, weight_init=xavier_uniform_, bias_init=zeros_initializer):
self.weight_init = weight_init
self.bias_init = bias_init
super().__init__(in_features, out_features, bias)
self.activation = activation
self.dropout = nn.Dropout(p=dropout_rate)
def reset_parameters(self):
"""
Reinitialize model parameters.
"""
self.weight_init(self.weight)
if self.bias is not None:
self.bias_init(self.bias)
def forward(self, inputs):
"""
Args:
inputs (dict of torch.Tensor): SchNetPack format dictionary of input tensors.
Returns:
torch.Tensor: Output of the dense layer.
"""
self.to(inputs.device)
y = super().forward(inputs)
if hasattr(self, 'dropout'):
y = self.dropout(y)
if self.activation:
y = self.activation(y)
return y
layer_types = {'linear': torch.nn.Linear, 'Tanh': torch.nn.Tanh, 'ReLU': torch.nn.ReLU, 'Dense': Dense, 'shifted_softplus': shifted_softplus, 'sigmoid': torch.nn.Sigmoid, 'Dropout': torch.nn.Dropout, 'LeakyReLU': torch.nn.LeakyReLU, 'ELU': torch.nn.ELU, 'swish': Swish, 'learnable_swish': LearnableSwish, 'softplus': torch.nn.Softplus}
def to_module(activation):
return layer_types[activation]()
ARGS = {
'activation': 'swish'
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1
- Imports
- numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type Swish — a Swish output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Swish 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
|
| AttentionPool |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("55d8c70e377b4a86") How it ran |
| InvariantMessage |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("f09c070242efedbf") How it ran |
| MeanPool |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("670901a6573e1934") How it ran |
| MessageBase |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("573a7b800820d725") How it ran |
| MessageBlock |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("9f1980fc08094e16") How it ran |
| Painn |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("450568a63ba4bedb") How it ran |
| ReadoutBlock |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("05495644c9588ed2") How it ran |
| SumPool |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("4b3ac9cd9d28db18") How it ran |
| UpdateBlock |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("1418df20e13d6afe") How it ran |
| add_stress |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("d31febe9a5aa1b51") How it ran |
| sum_and_grad |
Not yet run unverified (harvested, no recorded run) |
learningmatter-mit/NeuralForceField/nff/nn/models/painn.py code served (permissive licence) · get_code("5d9228f747be613d") How it ran |