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

Inverse of renormalization matrix being used? #13

Closed
sidnarayanan opened this issue Oct 29, 2020 · 1 comment
Closed

Inverse of renormalization matrix being used? #13

sidnarayanan opened this issue Oct 29, 2020 · 1 comment

Comments

@sidnarayanan
Copy link

Hi! Thanks for the speedy reference implementation in Pytorch.

I noticed something odd: I think you're multiplying by D (in eq 4) not D^-1 in linear_attention:

def linear_attention(q, k, v):
    D_inv = torch.einsum('...nd,...d->...n', q, k.sum(dim = -2))
    context = torch.einsum('...nd,...ne->...de', k, v)
    out = torch.einsum('...de,...nd,...n->...ne', context, q, D_inv)
    return out

The tensor named D_inv is actually D. Unless I'm missing something obvious, which hopefully I am.

[tagging @ncilfone because we discussed this recently]

@lucidrains
Copy link
Owner

🐛 🐝 🪲 🙏

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

No branches or pull requests

2 participants