MCPcopy Index your code
hub / github.com/tensorlayer/TensorLayer / DepthwiseConv2d

Class DepthwiseConv2d

tensorlayer/layers/convolution/depthwise_conv.py:18–162  ·  view source on GitHub ↗

Separable/Depthwise Convolutional 2D layer, see `tf.nn.depthwise_conv2d `__. Input: 4-D Tensor (batch, height, width, in_channels). Output: 4-D Tensor (batch, new height, new width, in_channel

Source from the content-addressed store, hash-verified

16
17
18class DepthwiseConv2d(Layer):
19 """Separable/Depthwise Convolutional 2D layer, see `tf.nn.depthwise_conv2d <https://tensorflow.google.cn/versions/r2.0/api_docs/python/tf/nn/depthwise_conv2d>`__.
20
21 Input:
22 4-D Tensor (batch, height, width, in_channels).
23 Output:
24 4-D Tensor (batch, new height, new width, in_channels * depth_multiplier).
25
26 Parameters
27 ------------
28 filter_size : tuple of 2 int
29 The filter size (height, width).
30 strides : tuple of 2 int
31 The stride step (height, width).
32 act : activation function
33 The activation function of this layer.
34 padding : str
35 The padding algorithm type: "SAME" or "VALID".
36 data_format : str
37 "channels_last" (NHWC, default) or "channels_first" (NCHW).
38 dilation_rate: tuple of 2 int
39 The dilation rate in which we sample input values across the height and width dimensions in atrous convolution. If it is greater than 1, then all values of strides must be 1.
40 depth_multiplier : int
41 The number of channels to expand to.
42 W_init : initializer
43 The initializer for the weight matrix.
44 b_init : initializer or None
45 The initializer for the bias vector. If None, skip bias.
46 in_channels : int
47 The number of in channels.
48 name : str
49 A unique layer name.
50
51 Examples
52 ---------
53 With TensorLayer
54
55 >>> net = tl.layers.Input([8, 200, 200, 32], name='input')
56 >>> depthwiseconv2d = tl.layers.DepthwiseConv2d(
57 ... filter_size=(3, 3), strides=(1, 1), dilation_rate=(2, 2), act=tf.nn.relu, depth_multiplier=2, name='depthwise'
58 ... )(net)
59 >>> print(depthwiseconv2d)
60 >>> output shape : (8, 200, 200, 64)
61
62
63 References
64 -----------
65 - tflearn&#x27;s `grouped_conv_2d <https://github.com/tflearn/tflearn/blob/3e0c3298ff508394f3ef191bcd7d732eb8860b2e/tflearn/layers/conv.py>`__
66 - keras&#x27;s `separableconv2d <https://keras.io/layers/convolutional/#separableconv2d>`__
67
68 """
69
70 # https://zhuanlan.zhihu.com/p/31551004 https://github.com/xiaohu2015/DeepLearning_tutorials/blob/master/CNNs/MobileNet.py
71 def __init__(
72 self,
73 filter_size=(3, 3),
74 strides=(1, 1),
75 act=None,

Callers 1

depthwise_conv_blockFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…