Skip to content

Commit

Permalink
return None from extractor if no attention layers
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Jan 29, 2022
1 parent 64a07f5 commit 25b3842
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 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 = 'vit-pytorch',
packages = find_packages(exclude=['examples']),
version = '0.26.5',
version = '0.26.6',
license='MIT',
description = 'Vision Transformer (ViT) - Pytorch',
author = 'Phil Wang',
Expand Down
2 changes: 1 addition & 1 deletion vit_pytorch/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ def forward(self, img):
target_device = self.device if self.device is not None else img.device
recordings = tuple(map(lambda t: t.to(target_device), self.recordings))

attns = torch.stack(recordings, dim = 1)
attns = torch.stack(recordings, dim = 1) if len(recordings) > 0 else None
return pred, attns

0 comments on commit 25b3842

Please sign in to comment.