We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I was looking for a drop in replacement for torch's TransformerEncoder:
nn.TransformerEncoder( nn.TransformerEncoderLayer(d_model=hidden_dim, nhead=nhead, dim_feedforward=dim_feedforward, batch_first=True), num_layers=num_layers )
And while this repo does offer a LocalTransformer (#10), the implementation expects a discrete input and a language modeling objective.
LocalTransformer
Would you be up for including a LocalTransformerLayer and then use it in the LocalTransformer? (pseudocode)
LocalTransformerLayer
class LocalTransformerLayer(nn.Module): def __init__(self, ...): self.attn = LocalMHA(dim=dim, dim_head=dim_head, heads=heads, dropout=attn_dropout, causal=causal, window_size=local_attn_window_size, use_xpos=use_xpos, xpos_scale_base=xpos_scale_base, use_rotary_pos_emb=not use_dynamic_pos_bias, prenorm=True, **kwargs), self.ff = FeedForward(dim=dim, mult=ff_mult, dropout=ff_dropout) self.dynamic_pos_bias = None if use_dynamic_pos_bias: self.dynamic_pos_bias = DynamicPositionBias(dim=dim // 2, heads=heads) def forward(self, x, mask = None, ): # dynamic pos bias attn_bias = None if exists(self.dynamic_pos_bias): w = self.local_attn_window_size attn_bias = self.dynamic_pos_bias(w, w * 2) x = self.attn(x, mask=mask, attn_bias=attn_bias) + x return self.ff(x) + x
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I was looking for a drop in replacement for torch's TransformerEncoder:
And while this repo does offer a
LocalTransformer
(#10), the implementation expects a discrete input and a language modeling objective.Would you be up for including a
LocalTransformerLayer
and then use it in theLocalTransformer
? (pseudocode)The text was updated successfully, but these errors were encountered: