Skip to main content

PyTorch implementation of Depthwise Separable Convolution

Project description

Unofficial PyTorch Module - Depthwise Separable Convolution

An illustration of Depthwise Separable Convolution. Credit: Depthwise Convolution Is All You Need for Learning Multiple Visual Domains.

total downloads monthly downloads license pypi version ci testing package testing

PyTorch (unofficial) implementation of Depthwise Separable Convolution. This type of convolution is introduced by Chollet in Xception: Deep Learning With Depthwise Separable Convolutions. This package provides SeparableConv1d, SeparableConv2d, SeparableConv3d, LazySeparableConv1d, LazySeparableConv2d, and LazySeparableConv3d.

Installation

Install separableconv-torch using pip (require: Python >=3.7).

pip install separableconv-torch

Parameters

Parameter Description Type
in_channels Number of channels in the input image int
out_channels Number of channels produced by the convolution int
kernel_size Size of the convolving kernel int or tuple
stride Stride of the convolution. Default: 1 int or tuple, optional
padding Padding added to all four sides of the input. Default: 0 int, tuple or str, optional
padding_mode 'zeros', 'reflect', 'replicate' or 'circular'. Default: 'zeros' string, optional
dilation Spacing between kernel elements. Default: 1 int or tuple, optional
depth_multiplier The number of depthwise convolution output channels for each input channel. The total number of depthwise convolution output channels will be equal to in_channels * depth_multiplier. Default: 1 int, optional
normalization_dw depthwise convolution normalization. Default: 'bn' str, optional
normalization_pw pointwise convolution normalization. Default: 'bn' str, optional
activation_dw depthwise convolution activation. Default: torch.nn.ReLU Callable[..., torch.nn.Module], optional
activation_pw pointwise convolution activation. Default: torch.nn.ReLU Callable[..., torch.nn.Module], optional
bias If True, adds a learnable bias to the output. Default: True bool, optional

Example Usage

For 1-dimensional case.
import torch
import separableconv.nn as nn

# set input
input = torch.randn(4, 10, 100)

# define model
m = nn.SeparableConv1d(10, 30, 3)

# process input through model
output = m(input)
For 2-dimensional case.
import torch
import separableconv.nn as nn

# set input
input = torch.randn(4, 10, 100, 100)

# define model
m = nn.SeparableConv2d(10, 30, 3)

# process input through model
output = m(input)
For 3-dimensional case.
import torch
import separableconv.nn as nn

# set input
input = torch.randn(4, 10, 100, 100, 100)

# define model
m = nn.SeparableConv3d(10, 30, 3)

# process input through model
output = m(input)
Stacked SeparableConv2d.
import torch
import separableconv.nn as nn

# set input
input = torch.randn(4, 3, 100, 100)

# define model
m = nn.Sequential(
        nn.SeparableConv2d(3, 32, 3),
        nn.SeparableConv2d(32, 64, 3),
        nn.SeparableConv2d(64, 96, 3))

# process input through model
output = m(input)
For lazy 2-dimensional case.
import torch
import separableconv.nn as nn

# set input
input = torch.randn(4, 10, 100, 100)

# define model
m = nn.LazySeparableConv2d(30, 3)

# process input through model
output = m(input)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

separableconv-torch-0.1.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

separableconv_torch-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file separableconv-torch-0.1.0.tar.gz.

File metadata

  • Download URL: separableconv-torch-0.1.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for separableconv-torch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6be6b822c0439c86cb5abaea1acdd3af8cb28f979542843259102041883d4eee
MD5 9f714c1575c62ad82418ce5a1efdfd02
BLAKE2b-256 a72dd0eeb05e35b1bc52b66885da8d274706681a7b902b4fd66fb2a5670b457f

See more details on using hashes here.

File details

Details for the file separableconv_torch-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for separableconv_torch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b35382ef3431093f0b72985d2108aba46031d1b45b3b86057501f6cc3c09380
MD5 b4b60a483ace14c0ba402a548edba77c
BLAKE2b-256 70f7ef0b3c5d396cde64ec83b6ecc57a5c80022d1313b09277c97afe79aab75a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page