Skip to content

Commit

Permalink
fix pixel calculation bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Mar 4, 2021
1 parent c421f9f commit 7621ce6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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 = 'transformer-in-transformer',
packages = find_packages(),
version = '0.0.3',
version = '0.0.5',
license='MIT',
description = 'Transformer in Transformer - Pytorch',
author = 'Phil Wang',
Expand Down
6 changes: 3 additions & 3 deletions transformer_in_transformer/tnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ def __init__(
self.patch_tokens = nn.Parameter(torch.randn(num_patch_tokens + 1, patch_dim))

self.to_pixel_tokens = nn.Sequential(
Rearrange('b c (p1 h) (p2 w) -> (b h w) c p1 p2', p1 = patch_size, p2 = patch_size),
nn.Unfold(pixel_width, stride = pixel_width),
Rearrange('b c (h p1) (w p2) -> (b h w) c p1 p2', p1 = patch_size, p2 = patch_size),
nn.Unfold(pixel_size, stride = pixel_size),
Rearrange('... c n -> ... n c'),
nn.Linear(3 * pixel_width ** 2, pixel_dim)
nn.Linear(3 * pixel_size ** 2, pixel_dim)
)

self.patch_pos_emb = nn.Parameter(torch.randn(num_patch_tokens + 1, patch_dim))
Expand Down

0 comments on commit 7621ce6

Please sign in to comment.