Skip to content

Commit

Permalink
update with the best type of downsample
Browse files Browse the repository at this point in the history
  • Loading branch information
lucidrains committed Aug 25, 2022
1 parent 967b1be commit 48361f6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -768,3 +768,13 @@ Anything! It is MIT licensed. In other words, you can freely copy / paste for yo
primaryClass = {cs.CV}
}
```

```bibtex
@article{Sunkara2022NoMS,
title = {No More Strided Convolutions or Pooling: A New CNN Building Block for Low-Resolution Images and Small Objects},
author = {Raja Sunkara and Tie Luo},
journal = {ArXiv},
year = {2022},
volume = {abs/2208.03641}
}
```
7 changes: 6 additions & 1 deletion imagen_pytorch/imagen_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,13 @@ def forward(self, x):
return self.net(x)

def Downsample(dim, dim_out = None):
# https://arxiv.org/abs/2208.03641 shows this is the most optimal way to downsample
# named SP-conv in the paper, but basically a pixel unshuffle
dim_out = default(dim_out, dim)
return nn.Conv2d(dim, dim_out, 4, 2, 1)
return nn.Sequential(
Rearrange('b c (h s1) (w s2) -> b (c s1 s2) h w', s1 = 2, s2 = 2),
nn.Conv2d(dim * 4, dim_out, 1)
)

class SinusoidalPosEmb(nn.Module):
def __init__(self, dim):
Expand Down
2 changes: 1 addition & 1 deletion imagen_pytorch/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.10.1'
__version__ = '1.11.0'

0 comments on commit 48361f6

Please sign in to comment.