Update davit.py

pull/1630/head
Fredo Guan 3 years ago
parent 3a4c89d659
commit ab1faea450

@ -35,12 +35,22 @@ from timm.data import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD
__all__ = ['DaViT'] __all__ = ['DaViT']
# modified nn.Sequential that includes a size tuple in the forward function # modified nn.Sequential that includes a size tuple in the forward function
'''
class SequentialWithSize(nn.Sequential): class SequentialWithSize(nn.Sequential):
def forward(self, x : Tensor, size: Tuple[int, int]): def forward(self, x : Tensor, size: Tuple[int, int]):
for module in self._modules.values(): for module in self._modules.values():
x, size = module(x, size) x, size = module(x, size)
return x, size return x, size
'''
class SequentialWithSize(nn.Sequential):
def __init__(self, *args, **kwargs):
super(SequentialWithSize, self).__init__(*args, **kwargs)
def forward(self, x : Tensor, size: Tuple[int, int]):
for module in self._modules.values():
x, size = module(x, size)
return x, size
class ConvPosEnc(nn.Module): class ConvPosEnc(nn.Module):
def __init__(self, dim : int, k : int=3, act : bool=False, normtype : str='none'): def __init__(self, dim : int, k : int=3, act : bool=False, normtype : str='none'):

Loading…
Cancel
Save