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

Fix scale calculation in attention mechanism #314

Merged
merged 1 commit into from
May 17, 2024

Conversation

dev-jinwoohong
Copy link
Contributor

Modified the scale calculation in the attention mechanism to use the instance's scale value instead of a local variable. This change ensures that the scaling factor is consistent with the object's state.

Changed from:
if exists(self.scale):
default_scale = q.shape[-1]
q = q * (scale / default_scale)

To:
if exists(self.scale):
default_scale = q.shape[-1]
q = q * (self.scale / default_scale)

Modified the scale calculation in the attention mechanism to use the instance's scale value instead of a local variable. This change ensures that the scaling factor is consistent with the object's state.

Changed from:
if exists(self.scale):
    default_scale = q.shape[-1]
    q = q * (scale / default_scale)

To:
if exists(self.scale):
    default_scale = q.shape[-1]
    q = q * (self.scale / default_scale)
@lucidrains
Copy link
Owner

@dev-jinwoohong oops, thanks!

@lucidrains lucidrains merged commit 356d7ee into lucidrains:main May 17, 2024
@dev-jinwoohong dev-jinwoohong deleted the develop branch May 20, 2024 04:39
WillyChap pushed a commit to WillyChap/denoising-diffusion-pytorch that referenced this pull request Sep 27, 2024
Fix scale calculation in attention mechanism
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