You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
420 B
28 lines
420 B
5 years ago
|
""" Layer/Module Helpers
|
||
5 years ago
|
|
||
|
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)
|
||
|
|
||
|
|
||
5 years ago
|
|
||
|
|
||
|
|
||
|
|