Skip to content

Commit

Permalink
pre layernorm the context too
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Jun 21, 2022
1 parent ddd160f commit 51cda7f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions perceiver_ar_pytorch/perceiver_ar_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ def __init__(
inner_dim = heads * dim_head

self.norm = nn.LayerNorm(dim)
self.context_norm = nn.LayerNorm(dim)

self.to_q = nn.Linear(dim, inner_dim, bias = False)
self.to_kv = nn.Linear(dim, inner_dim * 2, bias = False)
self.to_out = nn.Linear(inner_dim, dim)

def forward(self, x, context, context_mask = None, rotary_pos_emb = None):
x = self.norm(x)
context = self.context_norm(context)

q = self.to_q(x)

k_input, v_input = self.to_kv(x).chunk(2, dim = -1)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
setup(
name = 'perceiver-ar-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.4',
version = '0.0.5',
license='MIT',
description = 'Perceiver AR',
author = 'Phil Wang',
Expand Down

0 comments on commit 51cda7f

Please sign in to comment.