Logo
Explore Help
Register Sign In
mirrors/pytorch-image-models
1
0
Fork 0
You've already forked pytorch-image-models
mirror of https://github.com/huggingface/pytorch-image-models.git synced 2025-06-03 15:01:08 +08:00
Code Issues Projects Releases Wiki Activity
pytorch-image-models/timm/models/layers/helpers.py

28 lines
420 B
Python
Raw Normal View History

Layer refactoring continues, ResNet downsample rewrite for proper dilation in 3x3 and avg_pool cases * 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
2020-02-10 11:55:03 -08:00
""" Layer/Module Helpers
A bunch more layer reorg, splitting many layers into own files. Improve torchscript compatibility.
2020-02-09 14:46:28 -08:00
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)
Layer refactoring continues, ResNet downsample rewrite for proper dilation in 3x3 and avg_pool cases * 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
2020-02-10 11:55:03 -08:00
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.8 Page: 1022ms Template: 13ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API