MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / DepthConv

Function DepthConv

examples/ImageNetModels/shufflenet.py:23–37  ·  view source on GitHub ↗
(x, out_channel, kernel_shape, padding='SAME', stride=1,
              W_init=None, activation=tf.identity)

Source from the content-addressed store, hash-verified

21
22@layer_register(log_shape=True)
23def DepthConv(x, out_channel, kernel_shape, padding='SAME', stride=1,
24 W_init=None, activation=tf.identity):
25 in_shape = x.get_shape().as_list()
26 in_channel = in_shape[1]
27 assert out_channel % in_channel == 0, (out_channel, in_channel)
28 channel_mult = out_channel // in_channel
29
30 if W_init is None:
31 W_init = tf.variance_scaling_initializer(2.0)
32 kernel_shape = [kernel_shape, kernel_shape]
33 filter_shape = kernel_shape + [in_channel, channel_mult]
34
35 W = tf.get_variable('W', filter_shape, initializer=W_init)
36 conv = tf.nn.depthwise_conv2d(x, W, [1, 1, stride, stride], padding=padding, data_format='NCHW')
37 return activation(conv, name='output')
38
39
40@under_name_scope()

Callers 2

shufflenet_unitFunction · 0.85
shufflenet_unit_v2Function · 0.85

Calls 1

get_variableMethod · 0.80

Tested by

no test coverage detected