| CrossModalAttention |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("5b3de883fca30aef") 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
class CrossModalAttention(nn.Module):
def __init__(self, input_dim, num_heads, dropout):
super().__init__()
assert input_dim % num_heads == 0, 'input_dim must be divisible by num_heads'
self.input_dim = input_dim
self.num_heads = num_heads
self.head_dim = input_dim // num_heads
self.scale = self.head_dim ** (-0.5)
self.q_proj = nn.Linear(input_dim, input_dim, bias=False)
self.k_proj = nn.Linear(input_dim, input_dim, bias=False)
self.v_proj = nn.Linear(input_dim, input_dim, bias=False)
self.out_proj = nn.Linear(input_dim, input_dim, bias=False)
self.dropout = nn.Dropout(dropout)
def forward(self, query, context):
B_q, T_q, _ = query.shape
B_c, T_c, _ = context.shape
q = self.q_proj(query).reshape(B_q, T_q, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
k = self.k_proj(context).reshape(B_c, T_c, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
v = self.v_proj(context).reshape(B_c, T_c, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
scores = q @ k.transpose(-2, -1) * self.scale
attn_probs = torch.nn.functional.softmax(scores, dim=-1)
attn_weights = attn_probs
attn_probs = self.dropout(attn_probs)
out = attn_probs @ v
out = out.transpose(1, 2).reshape(B_q, T_q, self.input_dim)
out = self.out_proj(out)
return (out, attn_weights)
INIT_ARGS = {
'input_dim': 4,
'num_heads': 2,
'dropout': 0.1,
}
ARGS = {
'query': torch.randn(2, 3, 4),
'context': torch.randn(2, 5, 4),
}
if __name__ == '__main__':
model = CrossModalAttention(**INIT_ARGS)
output, attn_weights = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Attention weights shape: {attn_weights.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)
|
| CrossModalAttentionLayer |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("336c9365fc0d1a0c") 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
class CrossModalAttention(nn.Module):
def __init__(self, input_dim, num_heads, dropout):
super().__init__()
assert input_dim % num_heads == 0, 'input_dim must be divisible by num_heads'
self.input_dim = input_dim
self.num_heads = num_heads
self.head_dim = input_dim // num_heads
self.scale = self.head_dim ** (-0.5)
self.q_proj = nn.Linear(input_dim, input_dim, bias=False)
self.k_proj = nn.Linear(input_dim, input_dim, bias=False)
self.v_proj = nn.Linear(input_dim, input_dim, bias=False)
self.out_proj = nn.Linear(input_dim, input_dim, bias=False)
self.dropout = nn.Dropout(dropout)
def forward(self, query, context):
B_q, T_q, _ = query.shape
B_c, T_c, _ = context.shape
q = self.q_proj(query).reshape(B_q, T_q, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
k = self.k_proj(context).reshape(B_c, T_c, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
v = self.v_proj(context).reshape(B_c, T_c, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
scores = q @ k.transpose(-2, -1) * self.scale
attn_probs = F.softmax(scores, dim=-1)
attn_weights = attn_probs
attn_probs = self.dropout(attn_probs)
out = attn_probs @ v
out = out.transpose(1, 2).reshape(B_q, T_q, self.input_dim)
out = self.out_proj(out)
return (out, attn_weights)
class SwiGLU(nn.Module):
def __init__(self, input_dim, dropout):
super().__init__()
hidden_dim = int(input_dim * 2 * (2 / 3))
self.w1 = nn.Linear(input_dim, hidden_dim, bias=False)
self.w2 = nn.Linear(input_dim, hidden_dim, bias=False)
self.w3 = nn.Linear(hidden_dim, input_dim, bias=False)
self.dropout = nn.Dropout(dropout)
def forward(self, x):
x = F.silu(self.w1(x)) * self.w2(x)
x = self.w3(x)
x = self.dropout(x)
return x
class CrossModalAttentionLayer(nn.Module):
def __init__(self, input_dim, num_heads, dropout):
super().__init__()
self.cma = CrossModalAttention(input_dim=input_dim, num_heads=num_heads, dropout=dropout)
self.ffn = SwiGLU(input_dim=input_dim, dropout=dropout)
self.norm_q = nn.LayerNorm(input_dim)
self.norm_c = nn.LayerNorm(input_dim)
self.norm2 = nn.LayerNorm(input_dim)
self.dropout = nn.Dropout(dropout)
def forward(self, query, context):
attn_out, attn_weights = self.cma(self.norm_q(query), self.norm_c(context))
query = query + self.dropout(attn_out)
ffn_out = self.ffn(self.norm2(query))
query = query + self.dropout(ffn_out)
return (query, attn_weights)
INIT_ARGS = {
'input_dim': 4,
'num_heads': 2,
'dropout': 0.1,
}
ARGS = {
'query': torch.randn(2, 3, 4),
'context': torch.randn(2, 5, 4),
}
if __name__ == '__main__':
model = CrossModalAttentionLayer(**INIT_ARGS)
output, attn_weights = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Attention weights shape: {attn_weights.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)
|
| CrossModalFusionBlock |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("ba5914b0fa6f6b9f") 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
class SwiGLU(nn.Module):
def __init__(self, input_dim, dropout):
super().__init__()
hidden_dim = int(input_dim * 2 * (2 / 3))
self.w1 = nn.Linear(input_dim, hidden_dim, bias=False)
self.w2 = nn.Linear(input_dim, hidden_dim, bias=False)
self.w3 = nn.Linear(hidden_dim, input_dim, bias=False)
self.dropout = nn.Dropout(dropout)
def forward(self, x):
x = F.silu(self.w1(x)) * self.w2(x)
x = self.w3(x)
x = self.dropout(x)
return x
class CrossModalAttention(nn.Module):
def __init__(self, input_dim, num_heads, dropout):
super().__init__()
assert input_dim % num_heads == 0, 'input_dim must be divisible by num_heads'
self.input_dim = input_dim
self.num_heads = num_heads
self.head_dim = input_dim // num_heads
self.scale = self.head_dim ** (-0.5)
self.q_proj = nn.Linear(input_dim, input_dim, bias=False)
self.k_proj = nn.Linear(input_dim, input_dim, bias=False)
self.v_proj = nn.Linear(input_dim, input_dim, bias=False)
self.out_proj = nn.Linear(input_dim, input_dim, bias=False)
self.dropout = nn.Dropout(dropout)
def forward(self, query, context):
B_q, T_q, _ = query.shape
B_c, T_c, _ = context.shape
q = self.q_proj(query).reshape(B_q, T_q, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
k = self.k_proj(context).reshape(B_c, T_c, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
v = self.v_proj(context).reshape(B_c, T_c, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
scores = q @ k.transpose(-2, -1) * self.scale
attn_probs = F.softmax(scores, dim=-1)
attn_weights = attn_probs
attn_probs = self.dropout(attn_probs)
out = attn_probs @ v
out = out.transpose(1, 2).reshape(B_q, T_q, self.input_dim)
out = self.out_proj(out)
return (out, attn_weights)
class CrossModalAttentionLayer(nn.Module):
def __init__(self, input_dim, num_heads, dropout):
super().__init__()
self.cma = CrossModalAttention(input_dim=input_dim, num_heads=num_heads, dropout=dropout)
self.ffn = SwiGLU(input_dim=input_dim, dropout=dropout)
self.norm_q = nn.LayerNorm(input_dim)
self.norm_c = nn.LayerNorm(input_dim)
self.norm2 = nn.LayerNorm(input_dim)
self.dropout = nn.Dropout(dropout)
def forward(self, query, context):
attn_out, attn_weights = self.cma(self.norm_q(query), self.norm_c(context))
query = query + self.dropout(attn_out)
ffn_out = self.ffn(self.norm2(query))
query = query + self.dropout(ffn_out)
return (query, attn_weights)
class CrossModalFusionBlock(nn.Module):
def __init__(self, input_dim, num_heads, dropout):
super().__init__()
self.num_heads = num_heads
self.cma_layer = CrossModalAttentionLayer(input_dim=input_dim, num_heads=num_heads, dropout=dropout)
def forward(self, fusion, visual, text, audio):
query = fusion
context = torch.stack((visual, text, audio), dim=2)
B, T, D = query.shape
_, _, N, _ = context.shape
query_reshaped = query.reshape(B * T, 1, D)
context_reshaped = context.reshape(B * T, N, D)
query_update, attn_weights = self.cma_layer(query_reshaped, context_reshaped)
fusion_update = query_update.reshape(B, T, D)
attn_weights = attn_weights.squeeze(2).view(B, T, self.num_heads, N)
return (fusion_update, attn_weights)
INIT_ARGS = {
'input_dim': 4,
'num_heads': 2,
'dropout': 0.1,
}
ARGS = {
'fusion': torch.randn(2, 3, 4),
'visual': torch.randn(2, 3, 4),
'text': torch.randn(2, 3, 4),
'audio': torch.randn(2, 3, 4),
}
if __name__ == '__main__':
model = CrossModalFusionBlock(**INIT_ARGS)
fusion_update, attn_weights = model(**ARGS)
print(f"fusion_update shape: {fusion_update.shape}")
print(f"attn_weights shape: {attn_weights.shape}")
print("Success!")
- 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)
|
| ModalityEmbedding |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("79a184b673464a91") 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 3, dtype family float, shape (2, 5, 8) 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 ModalityEmbedding(nn.Module):
def __init__(self, input_dim):
super().__init__()
self.embedding = nn.Embedding(num_embeddings=4, embedding_dim=input_dim)
def forward(self, x, modality_index):
batch_size, seq_len, _ = x.shape
modality_tensor = torch.full((batch_size, seq_len), modality_index, dtype=torch.long, device=x.device)
return self.embedding(modality_tensor)
INIT_ARGS = {
'input_dim': 8
}
ARGS = {
'x': torch.randn(2, 5, 8),
'modality_index': 2
}
if __name__ == '__main__':
model = ModalityEmbedding(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Output:\n{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 3, dtype family float, shape (2, 5, 8) — shape (2, 5, 8) 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)
|
| SinusoidalTemporalPE |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("773afa0f598197d1") 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 3, dtype family float, shape (2, 6, 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 as nn
import math
class SinusoidalTemporalPE(nn.Module):
def __init__(self, input_dim, max_seq_len, dropout):
super().__init__()
assert input_dim % 2 == 0, 'input_dim must be even'
position = torch.arange(max_seq_len).unsqueeze(1)
div_term = torch.exp(torch.arange(0, input_dim, 2) * (-math.log(10000.0) / input_dim))
pe = torch.zeros(1, max_seq_len, input_dim)
pe[0, :, 0::2] = torch.sin(position * div_term)
pe[0, :, 1::2] = torch.cos(position * div_term)
self.register_buffer('pe', pe)
self.dropout = nn.Dropout(dropout)
def forward(self, x):
x = x + self.pe[:, :x.size(1), :]
x = self.dropout(x)
return x
INIT_ARGS = {
'input_dim': 4,
'max_seq_len': 8,
'dropout': 0.1
}
ARGS = {
'x': torch.randn(2, 6, 4)
}
if __name__ == '__main__':
model = SinusoidalTemporalPE(**INIT_ARGS)
output = model(**ARGS)
print(f"Input shape: {ARGS['x'].shape}")
print(f"Output shape: {output.shape}")
print("Test passed!")
- 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 3, dtype family float, shape (2, 6, 4) — shape (2, 6, 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)
|
| SwiGLU |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("7b38a0ea68d56f6f") 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 as nn
INIT_ARGS = {
'input_dim': 4,
'dropout': 0.1,
}
ARGS = {
'x': torch.randn(2, 4),
}
- 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)
|
| WindowedSelfAttention |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("e5eb2b6899045502") 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 3, dtype family float, shape (2, 5, 8) 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
# Initialize the class with small, distinct dimensions
INIT_ARGS = {
'input_dim': 8,
'num_heads': 2,
'dropout': 0.1,
'window_size': 3
}
# Arguments for the forward pass
ARGS = {
'x': torch.randn(2, 5, 8), # batch=2, seq_len=5, input_dim=8
'mask': torch.ones(2, 5, dtype=torch.bool) # batch=2, seq_len=5
}
# Construct and call the class
if __name__ == '__main__':
from torch.nn import Module
# Import the class (in practice it would be imported from the module)
class WindowedSelfAttention(nn.Module):
def __init__(self, input_dim, num_heads, dropout, window_size):
super().__init__()
assert input_dim % num_heads == 0, 'input_dim must be divisible by num_heads'
assert window_size >= 0, 'window_size must be non-negative'
assert window_size % 2 == 1 or window_size == 0, 'window_size must be odd or 0'
self.input_dim = input_dim
self.num_heads = num_heads
self.head_dim = input_dim // num_heads
self.scale = self.head_dim ** (-0.5)
self.use_window = window_size > 0
self.window_size = window_size
self.radius = window_size // 2
self.qkv_proj = nn.Linear(input_dim, input_dim * 3, bias=False)
self.out_proj = nn.Linear(input_dim, input_dim, bias=False)
self.dropout = nn.Dropout(dropout)
@staticmethod
def _edge_pad(x, radius):
if radius == 0:
return x
left = x[:, :1, :].expand(-1, radius, -1)
right = x[:, -1:, :].expand(-1, radius, -1)
return torch.cat((left, x, right), dim=1)
def forward(self, x, mask=None):
B, T, D = x.shape
if self.use_window:
qkv = self.qkv_proj(x)
q, k, v = qkv.chunk(3, dim=-1)
q = q.reshape(B, T, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
q = q.unsqueeze(-2)
padded_k = self._edge_pad(k, self.radius)
padded_k = padded_k.reshape(B, T + 2 * self.radius, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
k_windows = padded_k.unfold(2, self.window_size, 1)
padded_v = self._edge_pad(v, self.radius)
padded_v = padded_v.reshape(B, T + 2 * self.radius, self.num_heads, self.head_dim).permute(0, 2, 1, 3)
v_windows = padded_v.unfold(2, self.window_size, 1)
attn_scores = q @ k_windows * self.scale
attn_scores = attn_scores.squeeze(-2)
if mask is not None:
mask_windows = (~mask).view(B, T, 1)
padded_mask = torch.nn.functional.pad(mask_windows, (0, 0, self.radius, self.radius), value=True)
attn_mask = padded_mask.unfold(1, self.window_size, 1).squeeze(2).unsqueeze(1)
attn_scores = attn_scores.masked_fill(attn_mask, -1000000000.0)
attn_probs = torch.nn.functional.softmax(attn_scores, dim=-1)
attn_probs = self.dropout(attn_probs)
v_windows_permuted = v_windows.permute(0, 1, 2, 4, 3)
out = (attn_probs.unsqueeze(-2) @ v_windows_permuted).squeeze(-2)
out = out.transpose(1, 2).reshape(B, T, D)
out = self.out_proj(out)
else:
qkv = self.qkv_proj(x).reshape(B, T, 3, self.num_heads, self.head_dim).permute(2, 0, 3, 1, 4)
q, k, v = qkv.unbind(0)
scores = q @ k.transpose(-2, -1) * self.scale
if mask is not None:
attn_mask = (~mask).view(B, 1, 1, T).expand(-1, self.num_heads, T, -1)
scores = scores.masked_fill(attn_mask, -1000000000.0)
attn_probs = torch.nn.functional.softmax(scores, dim=-1)
attn_probs = self.dropout(attn_probs)
out = attn_probs @ v
out = out.transpose(1, 2).reshape(B, T, D)
out = self.out_proj(out)
return out
model = WindowedSelfAttention(**INIT_ARGS)
output = model(**ARGS)
print(f"Output shape: {output.shape}")
print(f"Expected shape: {ARGS['x'].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 3, dtype family float, shape (2, 5, 8) — shape (2, 5, 8) 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)
|
| WindowedSelfAttentionLayer |
Ran ran on a synthesized input |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("4edea45e6a96a4db") 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 3, 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
from collections import OrderedDict
INIT_ARGS = OrderedDict(
input_dim=4,
num_heads=2,
dropout=0.1,
window_size=3
)
# Construct input tensor and optional mask
B, T, D = 2, 6, 4 # batch, sequence length, feature dim
x = torch.randn(B, T, D)
mask = torch.zeros(B, T, dtype=torch.bool)
mask[0, 3:] = True # mask last 3 positions in first batch element
ARGS = OrderedDict(
x=x,
mask=mask
)
- 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 3, 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)
|
| MultiScaleTemporalBlock |
Not yet run unverified (harvested, no recorded run) |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("f59fc18b12fb43d6") How it ran |
| TripleSumm |
Not yet run unverified (harvested, no recorded run) |
smkim37/TripleSumm/models/model.py code served (permissive licence) · get_code("0b2c4c77f75b0c04") How it ran |