Repository navigation
Would optional whole-block scaling be a useful addition to NaFlexViT? #2830
Unanswered
Alihjt
asked this question in
Contributing
Replies: 1 comment
|
might be worth a comparison to SBB ViTs for in1k runs... they didn't use NaFlex in training but the recipe was tuned a bit more... e.g. https://huggingface.co/timm/vit_mediumd_patch16_rope_reg1_gap_256.sbb_in1k if that holds up could look at how it'd cleanly integrate into multiple vit archs.. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi @rwightman,
I’ve been experimenting with a small modification to NaFlexViT that I’m calling BlockScale, and wanted to ask whether you’d be interested in it as an optional feature in timm.
The idea is to apply a learnable per-channel multiplier after each complete transformer block, similar to layer scale:
output = block(x) * (1 + delta)
Each block has its own delta vector, initialized from a normal distribution with mean zero and standard deviation 1e-4, so the multiplier starts very close to one. The attention, MLP, and existing LayerScale stay unchanged. The scaling acts on the whole block output, including the residual stream. It adds only 2,304, 4,608, and 9,216 trainable parameters to the Tiny, Small, and Base models, respectively.
For training, I followed the Base recipe published on Hugging Face and also used it for Tiny and Small. Here are the completed seed-42 and 43 results: best EMA ImageNet-1k top-1 over 300 epochs, evaluated at 576 patch tokens.
Seed 42
Seed 43
Would you be open to a small PR for this? I have a working implementation and would be happy to share it and adapt the integration to whatever fits the codebase best.
Thanks for your work on timm!
All reactions