Skip to content

Commit

Permalink
take care of receiving single dna sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Oct 28, 2021
1 parent 074e2f9 commit 230e6c9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion enformer_pytorch/enformer_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,17 @@ def heads(self):
return self._heads

def forward(self, x):
no_batch = (x.ndim == 1)
if no_batch:
x = rearrange(x, 'n -> () n')

if x.dtype == torch.long:
x = F.one_hot(x, num_classes = self.num_alphabet)

x = self._trunk(x.float())
return map_values(lambda fn: fn(x), self._heads)
out = map_values(lambda fn: fn(x), self._heads)

if no_batch:
out = map_values(lambda t: rearrange(t, '() ... -> ...'), out)

return out
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 = 'enformer-pytorch',
packages = find_packages(exclude=[]),
version = '0.0.7',
version = '0.0.8',
license='MIT',
description = 'Enformer - Pytorch',
author = 'Phil Wang',
Expand Down

0 comments on commit 230e6c9

Please sign in to comment.