MobileNetV3¶
- class torch_ecg.models.MobileNetV3(in_channels: int, **config: torch_ecg.cfg.CFG)[source]¶
Bases:
torch.nn.modules.container.Sequential
,torch_ecg.utils.utils_nn.SizeMixin
,torch_ecg.utils.misc.CitationMixin
MobileNet V3.
MobileNet V3 1 is an incremental improvement of MobileNet series. MobileNet V3 uses neural architecture search instead of hand-designed architectures to find the optimal network structure. MobileNet V3 has implementions in Torchvision 2, which serves as a reference for this implementation for ECG tasks.
- Parameters
in_channels (int) – Number of channels in the input signal tensor.
config (dict) –
Other hyper-parameters of the Module, ref. corr. config file. Keyword arguments that must be set:
groups: int, number of groups in the convolutional layer(s) other than depthwise convolutions.
norm: bool or str or Module, normalization layer.
bias: bool, whether to use bias in the convolutional layer(s).
width_multiplier: float, multiplier of the number of output channels of the pointwise convolution.
stem: CFG, config of the stem block, with the following keys:
num_filters: int or Sequence[int], number of filters in the first convolutional layer(s).
filter_lengths: int or Sequence[int], filter lengths (kernel sizes) in the first convolutional layer(s).
subsample_lengths: int or Sequence[int], subsample lengths (strides) in the first convolutional layer(s).
inv_res: CFG, config of the inverted residual blocks, with the following keys:
in_channels: Sequence[int], number of input channels.
n_blocks: Sequence[int], number of inverted residual blocks.
expansions: sequence of floats or sequence of sequence of floats, expansion ratios of the inverted residual blocks.
filter_lengths: sequence of ints or sequence of sequence of ints, filter length of the depthwise convolution in the inverted residual blocks.
stride: sequence of ints or sequence of sequence of ints, optional, stride of the depthwise convolution in the inverted residual blocks, defaults to
[2] + [1] * (n_blocks - 1)
.groups: int, default 1, number of groups in the expansion and pointwise convolution in the inverted residual blocks.
dilation: sequence of ints or sequence of sequence of ints, optional, dilation of the depthwise convolution in the inverted residual blocks.
batch_norm: bool or str or nn.Module, default True, normalization layer to use, defaults to batch normalization.
activation: str or nn.Module or sequence of str or torch.nn.Module, activation function to use.
width_multiplier: float or sequence of floats, default 1.0, width multiplier of the inverted residual blocks.
out_channels: sequence of ints or sequence of Sequence[int], optional, number of output channels of the inverted residual blocks, defaults to
2 * in_channels
.attn: sequence of CFG or sequence of sequence of CFG, optional, config of attention layer to use, defaults to None.
- exit_flow: CFG,
config of the exit flow blocks, with the following keys:
num_filters: int or Sequence[int], number of filters in the final convolutional layer(s).
filter_lengths: int or Sequence[int], filter lengths (kernel sizes) in the final convolutional layer(s).
subsample_lengths: int or Sequence[int], subsample lengths (strides) in the final convolutional layer(s).
References
- 1
Howard, A., Sandler, M., Chu, G., Chen, L. C., Chen, B., Tan, M., … & Adam, H. (2019). Searching for mobilenetv3. In Proceedings of the IEEE International Conference on Computer Vision (pp. 1314-1324).
- 2
https://github.com/pytorch/vision/blob/master/torchvision/models/mobilenetv3.py