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

Remove zero init and constant biasing for to_gate #304

Merged
merged 2 commits into from
Oct 3, 2024

Conversation

amorehead
Copy link
Contributor

@amorehead amorehead commented Oct 3, 2024

Attention pair biasing uses a simple linear (no bias) and a sigmoid function to gate the attention output logits, as shown below
image

nn.init.constant_(gate_linear.bias, init_gate_bias)

self.to_gates = gate_linear
self.to_gates = nn.Sequential(nn.Linear(dim, dim_inner, bias = False), nn.Sigmoid())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to use the LinearNoBias here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to duplicate to avoid circular imports

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that's fine, dryness is overrated

Copy link
Owner

@lucidrains lucidrains left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh my bad, thought this was a constant in this file!

@lucidrains lucidrains merged commit ffe6a89 into lucidrains:main Oct 3, 2024
11 checks passed
@amorehead amorehead deleted the patch-1 branch October 3, 2024 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants