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.
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
, and SeparableConv3d
.
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file separableconv-torch-0.0.1.tar.gz
.
File metadata
- Download URL: separableconv-torch-0.0.1.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b65cacd35c36e160f64284c6329d5824aa97bf93e104402422cdbe673a23f2c7 |
|
MD5 | 7284eaef4254e0ff97adeb3fe57132c8 |
|
BLAKE2b-256 | 1f8cea4d2fc22af708bed6ef29b65954eabfa31cb073d39c0dd5802ba6dd3013 |
File details
Details for the file separableconv_torch-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: separableconv_torch-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.10.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e05ebac7963ff89b9eb76ad424a98759416be2ace692f0025b1952d8bc43250e |
|
MD5 | 725ff0705591dec91d24dc8744ee29dd |
|
BLAKE2b-256 | 893cb7baeb7228dae836904b6ac03d775d66c69838a6c5c958f2012298cf0531 |