Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set bias=True for linear layer (#526) #527

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,18 @@ def assert_expected_namedtuple(


def init_weights_with_constant(model: nn.Module, constant: float = 1.0) -> None:
for p in model.parameters():
for n, p in model.named_parameters():
nn.init.constant_(p, constant)
# reduce the change to the tests
for k in {
"text_projection.bias",
"pooled_projection.bias",
"output_projection.bias",
"vision_proj.bias",
}:
if n.endswith(k):
nn.init.constant_(p, 0.0)
break


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