(x, out_channel, kernel_shape, padding='SAME', stride=1,
W_init=None, activation=tf.identity)
| 21 | |
| 22 | @layer_register(log_shape=True) |
| 23 | def 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() |
no test coverage detected