mirror of
https://github.com/huggingface/pytorch-image-models.git
synced 2025-06-03 15:01:08 +08:00
* select_conv2d -> create_conv2d * added create_attn to create attention module from string/bool/module * factor padding helpers into own file, use in both conv2d_same and avg_pool2d_same * add some more test eca resnet variants * minor tweaks, naming, comments, consistency
28 lines
420 B
Python
28 lines
420 B
Python
""" Layer/Module Helpers
|
|
|
|
Hacked together by Ross Wightman
|
|
"""
|
|
from itertools import repeat
|
|
from torch._six import container_abcs
|
|
|
|
|
|
# From PyTorch internals
|
|
def _ntuple(n):
|
|
def parse(x):
|
|
if isinstance(x, container_abcs.Iterable):
|
|
return x
|
|
return tuple(repeat(x, n))
|
|
return parse
|
|
|
|
|
|
tup_single = _ntuple(1)
|
|
tup_pair = _ntuple(2)
|
|
tup_triple = _ntuple(3)
|
|
tup_quadruple = _ntuple(4)
|
|
|
|
|
|
|
|
|
|
|
|
|