Implement a Swin Transformer Block (Shifted Window Attention) in PyTorch
Hardmodern-architecturesauto-graded
Build a Swin Transformer block from scratch: window partition, shifted-window attention masks, and a learned relative position bias.
Solve it
Check your answer
The grader verifies properties of your implementation, so a correct solution written differently from ours still passes.
pip install torchleet
from torchleet import check
check("swin-transformer", window_partition, window_reverse, window_attention, create_shifted_window_mask, SwinBlock, relative_position_index, SwinBlockRelPosBias)