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

Calculation of Q in the code #35

Open
mengyangz86 opened this issue Apr 18, 2023 · 1 comment
Open

Calculation of Q in the code #35

mengyangz86 opened this issue Apr 18, 2023 · 1 comment

Comments

@mengyangz86
Copy link

        Q = self.attention_layernorms[i](seqs)  ** #Why Q should be calculated this way, should not be seqs * w_q?**
        mha_outputs, _ = self.attention_layers[i](Q, seqs, seqs, 
                                        attn_mask=attention_mask)
                                        # key_padding_mask=timeline_mask
                                        # need_weights=False) this arg do not work?
        seqs = Q + mha_outputs  **# This sentence is not very understandable**
        seqs = torch.transpose(seqs, 0, 1)

        seqs = self.forward_layernorms[i](seqs)
        seqs = self.forward_layers[i](seqs)
        seqs *=  ~timeline_mask.unsqueeze(-1)
@pmixer
Copy link
Owner

pmixer commented Apr 19, 2023

It's just a layernorm layer, people use it randomly to normalize embedding values, guess what you mean by seqs * w_q is part of attention_layer, do not need to be coded separately in explicit way.

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