Skip to content

Commit ffaf97f

Browse files
committed
MaxxVit! A very configurable MaxVit and CoAtNet impl with lots of goodies..
1 parent 8c9696c commit ffaf97f

File tree

4 files changed

+1706
-1
lines changed

4 files changed

+1706
-1
lines changed

timm/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from .inception_v3 import *
2626
from .inception_v4 import *
2727
from .levit import *
28+
from .maxxvit import *
2829
from .mlp_mixer import *
2930
from .mobilenetv3 import *
3031
from .mobilevit import *

timm/models/layers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .filter_response_norm import FilterResponseNormTlu2d, FilterResponseNormAct2d
2222
from .gather_excite import GatherExcite
2323
from .global_context import GlobalContext
24-
from .helpers import to_ntuple, to_2tuple, to_3tuple, to_4tuple, make_divisible
24+
from .helpers import to_ntuple, to_2tuple, to_3tuple, to_4tuple, make_divisible, extend_tuple
2525
from .inplace_abn import InplaceAbn
2626
from .linear import Linear
2727
from .mixed_conv2d import MixedConv2d

timm/models/layers/helpers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,15 @@ def make_divisible(v, divisor=8, min_value=None, round_limit=.9):
2929
if new_v < round_limit * v:
3030
new_v += divisor
3131
return new_v
32+
33+
34+
def extend_tuple(x, n):
35+
# pdas a tuple to specified n by padding with last value
36+
if not isinstance(x, (tuple, list)):
37+
x = (x,)
38+
else:
39+
x = tuple(x)
40+
pad_n = n - len(x)
41+
if pad_n <= 0:
42+
return x[:n]
43+
return x + (x[-1],) * pad_n

0 commit comments

Comments
 (0)