Skip to content

Commit 7568f78

Browse files
Update init of batched MLPResidualBlock.
1 parent e04036e commit 7568f78

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/eir/models/output/tabular/shared_mlp_residual.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import math
12
from dataclasses import dataclass
23
from typing import TYPE_CHECKING
34

@@ -180,8 +181,12 @@ def _build_batched(
180181
self.batched_proj_weight = nn.Parameter(
181182
torch.empty(n_groups, max_outputs, fc_task_dim)
182183
)
183-
self.batched_proj_bias = nn.Parameter(torch.zeros(n_groups, 1, max_outputs))
184-
nn.init.kaiming_uniform_(self.batched_proj_weight.view(-1, fc_task_dim))
184+
self.batched_proj_bias = nn.Parameter(torch.empty(n_groups, 1, max_outputs))
185+
for g in range(n_groups):
186+
nn.init.kaiming_uniform_(self.batched_proj_weight[g], a=math.sqrt(5))
187+
fan_in = fc_task_dim
188+
bound = 1 / math.sqrt(fan_in)
189+
nn.init.uniform_(self.batched_proj_bias[g], -bound, bound)
185190

186191
def forward(
187192
self,

0 commit comments

Comments
 (0)