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

Does here exist some inconsistency about this code ? #25

Open
fakerhbj opened this issue Mar 9, 2021 · 1 comment
Open

Does here exist some inconsistency about this code ? #25

fakerhbj opened this issue Mar 9, 2021 · 1 comment

Comments

@fakerhbj
Copy link

fakerhbj commented Mar 9, 2021

     # flat_q, flat_k, flat_v
    # (batch_size, Nh, height * width, dvh or dkh)

   flat_q = torch.reshape(q, (N, Nh, dk // Nh, H * W))
    flat_k = torch.reshape(k, (N, Nh, dk // Nh, H * W))
    flat_v = torch.reshape(v, (N, Nh, dv // Nh, H * W))
@linusyh
Copy link

linusyh commented Apr 8, 2021

# attn_out
# (batch, Nh, height * width, dvh)
attn_out = torch.matmul(weights, flat_v.transpose(2, 3)) # shape: (batch, Nh, height * width, dvh)
attn_out = torch.reshape(attn_out, (batch, self.Nh, self.dv // self.Nh, height, width))

I have similar questions about this part as well. Doesn't reshaping like this messes up the order of values?

Really hope to get some clarification on this. Many thanks.

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