XResNet1d

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


source

xresnet1d50_deeper


def xresnet1d50_deeper(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d34_deeper


def xresnet1d34_deeper(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d18_deeper


def xresnet1d18_deeper(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d50_deep


def xresnet1d50_deep(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d34_deep


def xresnet1d34_deep(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d18_deep


def xresnet1d18_deep(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d152


def xresnet1d152(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d101


def xresnet1d101(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d50


def xresnet1d50(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d34


def xresnet1d34(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.


source

xresnet1d18


def xresnet1d18(
    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: 1>, 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:Union=1, padding_mode:Literal='zeros',
    device:NoneType=None, dtype:NoneType=None
):

Call self as a function.

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)