Skip to content

Commit e4d288b

Browse files
zhangtemplarfacebook-github-bot
authored andcommitted
set bias=True for linear layer (#527)
Summary: Pull Request resolved: #527 Pull Request resolved: #526 1. for output projection in text decoder, change bias=False to True. In many other places, e.g., LP head, ember's output module and LLAVA, they are using bias=True (which is default value in Linear). 2. add configuration of using MLP instead of attention pooler for vision adapter; Reviewed By: Bellaktris Differential Revision: D55897450 Privacy Context Container: 303860477774201 fbshipit-source-id: 8e012b0c3d37566364f216dbfa8aec389142afe1
1 parent dbeed97 commit e4d288b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

tests/test_utils.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,18 @@ def assert_expected_namedtuple(
192192

193193

194194
def init_weights_with_constant(model: nn.Module, constant: float = 1.0) -> None:
195-
for p in model.parameters():
195+
for n, p in model.named_parameters():
196196
nn.init.constant_(p, constant)
197+
# reduce the change to the tests
198+
for k in {
199+
"text_projection.bias",
200+
"pooled_projection.bias",
201+
"output_projection.bias",
202+
"vision_proj.bias",
203+
}:
204+
if n.endswith(k):
205+
nn.init.constant_(p, 0.0)
206+
break
197207

198208

199209
def tensor_hash(x: torch.tensor, scaling=0.05, buckets=1000) -> torch.tensor:

0 commit comments

Comments
 (0)