Skip to content

Commit

Permalink
add downsampling at beginning of stage
Browse files Browse the repository at this point in the history
  • Loading branch information
gau-nernst committed Aug 10, 2023
1 parent 7948762 commit 232a50b
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions vision_toolbox/backbones/swin.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,15 @@ def __init__(
self.stages = nn.Sequential()
for i, (depth, window_size) in enumerate(zip(depths, window_sizes)):
stage = nn.Sequential()
for i in range(depth):
blk = SwinBlock(input_size, d_model, n_heads, window_size, i % 2, mlp_ratio, bias, dropout, norm, act)
stage.append(blk)

if i < len(depths) - 1:
if i > 0:
stage.append(PatchMerging(d_model, norm))
input_size //= 2
d_model *= 2
n_heads *= 2

for i in range(depth):
blk = SwinBlock(input_size, d_model, n_heads, window_size, i % 2, mlp_ratio, bias, dropout, norm, act)
stage.append(blk)
self.stages.append(stage)

self.head_norm = norm(d_model)
Expand Down

0 comments on commit 232a50b

Please sign in to comment.