MobileNetV1

class torch_ecg.models.MobileNetV1(in_channels: int, **config)[source]

Bases: torch.nn.modules.container.Sequential, torch_ecg.utils.utils_nn.SizeMixin, torch_ecg.utils.misc.CitationMixin

MobileNet V1.

Similar to Xception, but without skip connections. Separable convolutions are slightly different too.

normal conv –> entry flow (separable convs, down sample and double channels every other conv) –> middle flow (separable convs, no down sampling, stationary number of channels) –> exit flow (separable convs, down sample and double channels at each conv).

MobileNet V1 is a light-weight model intended for mobile devices, originally proposed in 1.

Parameters
  • in_channels (int) – Number of channels in the input.

  • config (dict) –

    Other hyper-parameters of the Module, ref. corresponding config file. key word arguments that have to be set in 3 sub-dict, namely in “entry_flow”, “middle_flow”, and “exit_flow”, including

    • out_channels: int, number of channels of the output.

    • kernel_size: int, kernel size of down sampling. If not specified, defaults to down_scale.

    • groups: int, connection pattern (of channels) of the inputs and outputs.

    • padding: int, zero-padding added to both sides of the input.

    • batch_norm: bool or Module, batch normalization, the Module itself or (if is bool) whether or not to use torch.nn.BatchNorm1d.

References

1

Howard, A. G., Zhu, M., Chen, B., Kalenichenko, D., Wang, W., Weyand, T., … & Adam, H. (2017). Mobilenets: Efficient convolutional neural networks for mobile vision applications. arXiv preprint arXiv:1704.04861.

compute_output_shape(seq_len: Optional[int] = None, batch_size: Optional[int] = None) Sequence[Optional[int]][source]

Compute the output shape of the model.

Parameters
  • seq_len (int, optional) – Length of the input tensor.

  • batch_size (int, optional,) – The batch size of the input tensor.

Returns

output_shape – Output shape of the model.

Return type

sequence