Fix RBF time-bias initialization

This commit is contained in:
2026-07-24 14:39:15 +08:00
parent 20c99484f3
commit 7b48cb8425
3 changed files with 50 additions and 2 deletions

View File

@@ -111,7 +111,10 @@ class TemporalAttention(nn.Module):
# Layer-specific projection from shared RBF basis activations to per-head attention bias.
self.rbf_proj = nn.Linear(n_rbf_bases, n_head, bias=False)
self.time_bias_scale = nn.Parameter(torch.tensor(0.0))
# Keep the initial RBF attention bias exactly zero through the
# zero-initialized projection, while leaving that projection with a
# live gradient from the first optimization step.
self.time_bias_scale = nn.Parameter(torch.tensor(1.0))
self.resid_drop = nn.Dropout(dropout)
self.reset_parameters()