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

Function shufflenet_unit_v2

examples/ImageNetModels/shufflenet.py:78–96  ·  view source on GitHub ↗
(l, out_channel, stride)

Source from the content-addressed store, hash-verified

76
77@layer_register()
78def shufflenet_unit_v2(l, out_channel, stride):
79 if stride == 1:
80 shortcut, l = tf.split(l, 2, axis=1)
81 else:
82 shortcut, l = l, l
83 shortcut_channel = int(shortcut.shape[1])
84
85 l = Conv2D('conv1', l, out_channel // 2, 1, activation=BNReLU)
86 l = DepthConv('dconv', l, out_channel // 2, 3, stride=stride)
87 l = BatchNorm('dconv_bn', l)
88 l = Conv2D('conv2', l, out_channel - shortcut_channel, 1, activation=BNReLU)
89
90 if stride == 2:
91 shortcut = DepthConv('shortcut_dconv', shortcut, shortcut_channel, 3, stride=2)
92 shortcut = BatchNorm('shortcut_dconv_bn', shortcut)
93 shortcut = Conv2D('shortcut_conv', shortcut, shortcut_channel, 1, activation=BNReLU)
94 output = tf.concat([shortcut, l], axis=1)
95 output = channel_shuffle(output, 2)
96 return output
97
98
99@layer_register(log_shape=True)

Callers 1

shufflenet_stageFunction · 0.85

Calls 4

Conv2DFunction · 0.85
DepthConvFunction · 0.85
channel_shuffleFunction · 0.85
BatchNormFunction · 0.50

Tested by

no test coverage detected