XResNet1d

This is a modified version of fastai’s XResNet model in github


source

xresnet1d50_deeper

 xresnet1d50_deeper (c_in, c_out, act=<class
                     'torch.nn.modules.activation.ReLU'>, stride=1,
                     groups=1, reduction=None, nh1=None, nh2=None,
                     dw=False, g2=1, sa=False, sym=False,
                     norm_type=<NormType.Batch: 1>, act_cls=<class
                     'torch.nn.modules.activation.ReLU'>, ndim=2, ks=3,
                     pool=<function AvgPool>, pool_first=True,
                     padding=None, bias=None, bn_1st=True,
                     transpose=False, init='auto', xtra=None,
                     bias_std=0.01, dilation:Union[int,Tuple[int,int]]=1,
                     padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d34_deeper

 xresnet1d34_deeper (c_in, c_out, act=<class
                     'torch.nn.modules.activation.ReLU'>, stride=1,
                     groups=1, reduction=None, nh1=None, nh2=None,
                     dw=False, g2=1, sa=False, sym=False,
                     norm_type=<NormType.Batch: 1>, act_cls=<class
                     'torch.nn.modules.activation.ReLU'>, ndim=2, ks=3,
                     pool=<function AvgPool>, pool_first=True,
                     padding=None, bias=None, bn_1st=True,
                     transpose=False, init='auto', xtra=None,
                     bias_std=0.01, dilation:Union[int,Tuple[int,int]]=1,
                     padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d18_deeper

 xresnet1d18_deeper (c_in, c_out, act=<class
                     'torch.nn.modules.activation.ReLU'>, stride=1,
                     groups=1, reduction=None, nh1=None, nh2=None,
                     dw=False, g2=1, sa=False, sym=False,
                     norm_type=<NormType.Batch: 1>, act_cls=<class
                     'torch.nn.modules.activation.ReLU'>, ndim=2, ks=3,
                     pool=<function AvgPool>, pool_first=True,
                     padding=None, bias=None, bn_1st=True,
                     transpose=False, init='auto', xtra=None,
                     bias_std=0.01, dilation:Union[int,Tuple[int,int]]=1,
                     padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d50_deep

 xresnet1d50_deep (c_in, c_out, act=<class
                   'torch.nn.modules.activation.ReLU'>, stride=1,
                   groups=1, reduction=None, nh1=None, nh2=None, dw=False,
                   g2=1, sa=False, sym=False, norm_type=<NormType.Batch:
                   1>, act_cls=<class 'torch.nn.modules.activation.ReLU'>,
                   ndim=2, ks=3, pool=<function AvgPool>, pool_first=True,
                   padding=None, bias=None, bn_1st=True, transpose=False,
                   init='auto', xtra=None, bias_std=0.01,
                   dilation:Union[int,Tuple[int,int]]=1,
                   padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d34_deep

 xresnet1d34_deep (c_in, c_out, act=<class
                   'torch.nn.modules.activation.ReLU'>, stride=1,
                   groups=1, reduction=None, nh1=None, nh2=None, dw=False,
                   g2=1, sa=False, sym=False, norm_type=<NormType.Batch:
                   1>, act_cls=<class 'torch.nn.modules.activation.ReLU'>,
                   ndim=2, ks=3, pool=<function AvgPool>, pool_first=True,
                   padding=None, bias=None, bn_1st=True, transpose=False,
                   init='auto', xtra=None, bias_std=0.01,
                   dilation:Union[int,Tuple[int,int]]=1,
                   padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d18_deep

 xresnet1d18_deep (c_in, c_out, act=<class
                   'torch.nn.modules.activation.ReLU'>, stride=1,
                   groups=1, reduction=None, nh1=None, nh2=None, dw=False,
                   g2=1, sa=False, sym=False, norm_type=<NormType.Batch:
                   1>, act_cls=<class 'torch.nn.modules.activation.ReLU'>,
                   ndim=2, ks=3, pool=<function AvgPool>, pool_first=True,
                   padding=None, bias=None, bn_1st=True, transpose=False,
                   init='auto', xtra=None, bias_std=0.01,
                   dilation:Union[int,Tuple[int,int]]=1,
                   padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d152

 xresnet1d152 (c_in, c_out, act=<class
               'torch.nn.modules.activation.ReLU'>, stride=1, groups=1,
               reduction=None, nh1=None, nh2=None, dw=False, g2=1,
               sa=False, sym=False, norm_type=<NormType.Batch: 1>,
               act_cls=<class 'torch.nn.modules.activation.ReLU'>, ndim=2,
               ks=3, pool=<function AvgPool>, pool_first=True,
               padding=None, bias=None, bn_1st=True, transpose=False,
               init='auto', xtra=None, bias_std=0.01,
               dilation:Union[int,Tuple[int,int]]=1,
               padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d101

 xresnet1d101 (c_in, c_out, act=<class
               'torch.nn.modules.activation.ReLU'>, stride=1, groups=1,
               reduction=None, nh1=None, nh2=None, dw=False, g2=1,
               sa=False, sym=False, norm_type=<NormType.Batch: 1>,
               act_cls=<class 'torch.nn.modules.activation.ReLU'>, ndim=2,
               ks=3, pool=<function AvgPool>, pool_first=True,
               padding=None, bias=None, bn_1st=True, transpose=False,
               init='auto', xtra=None, bias_std=0.01,
               dilation:Union[int,Tuple[int,int]]=1,
               padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d50

 xresnet1d50 (c_in, c_out, act=<class 'torch.nn.modules.activation.ReLU'>,
              stride=1, groups=1, reduction=None, nh1=None, nh2=None,
              dw=False, g2=1, sa=False, sym=False,
              norm_type=<NormType.Batch: 1>, act_cls=<class
              'torch.nn.modules.activation.ReLU'>, ndim=2, ks=3,
              pool=<function AvgPool>, pool_first=True, padding=None,
              bias=None, bn_1st=True, transpose=False, init='auto',
              xtra=None, bias_std=0.01,
              dilation:Union[int,Tuple[int,int]]=1,
              padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d34

 xresnet1d34 (c_in, c_out, act=<class 'torch.nn.modules.activation.ReLU'>,
              stride=1, groups=1, reduction=None, nh1=None, nh2=None,
              dw=False, g2=1, sa=False, sym=False,
              norm_type=<NormType.Batch: 1>, act_cls=<class
              'torch.nn.modules.activation.ReLU'>, ndim=2, ks=3,
              pool=<function AvgPool>, pool_first=True, padding=None,
              bias=None, bn_1st=True, transpose=False, init='auto',
              xtra=None, bias_std=0.01,
              dilation:Union[int,Tuple[int,int]]=1,
              padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None

source

xresnet1d18

 xresnet1d18 (c_in, c_out, act=<class 'torch.nn.modules.activation.ReLU'>,
              stride=1, groups=1, reduction=None, nh1=None, nh2=None,
              dw=False, g2=1, sa=False, sym=False,
              norm_type=<NormType.Batch: 1>, act_cls=<class
              'torch.nn.modules.activation.ReLU'>, ndim=2, ks=3,
              pool=<function AvgPool>, pool_first=True, padding=None,
              bias=None, bn_1st=True, transpose=False, init='auto',
              xtra=None, bias_std=0.01,
              dilation:Union[int,Tuple[int,int]]=1,
              padding_mode:str='zeros', device=None, dtype=None)
Type Default Details
c_in
c_out
act type ReLU
stride int 1
groups int 1
reduction NoneType None
nh1 NoneType None
nh2 NoneType None
dw bool False
g2 int 1
sa bool False
sym bool False
norm_type NormType NormType.Batch
act_cls type ReLU
ndim int 2
ks int 3
pool function AvgPool
pool_first bool True
padding NoneType None
bias NoneType None
bn_1st bool True
transpose bool False
init str auto
xtra NoneType None
bias_std float 0.01
dilation typing.Union[int, typing.Tuple[int, int]] 1
padding_mode str zeros TODO: refine this type
device NoneType None
dtype NoneType None
bs, c_in, seq_len = 2, 4, 32
c_out = 2
x = torch.rand(bs, c_in, seq_len)
archs = [
    xresnet1d18, xresnet1d34, xresnet1d50, 
    xresnet1d18_deep, xresnet1d34_deep, xresnet1d50_deep, xresnet1d18_deeper,
    xresnet1d34_deeper, xresnet1d50_deeper
#     # Long test
#     xresnet1d101, xresnet1d152,
]
for i, arch in enumerate(archs):
    print(i, arch.__name__)
    test_eq(arch(c_in, c_out, sa=True, act=Mish)(x).shape, (bs, c_out))
0 xresnet1d18
1 xresnet1d34
2 xresnet1d50
3 xresnet1d18_deep
4 xresnet1d34_deep
5 xresnet1d50_deep
6 xresnet1d18_deeper
7 xresnet1d34_deeper
8 xresnet1d50_deeper
m = xresnet1d34(4, 2, act=Mish)
test_eq(len(get_layers(m, is_bn)), 38)
test_eq(check_weight(m, is_bn)[0].sum(), 22)