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

Function se_bottleneck

examples/ResNet/resnet_model.py:89–104  ·  view source on GitHub ↗
(l, ch_out, stride)

Source from the content-addressed store, hash-verified

87
88
89def se_bottleneck(l, ch_out, stride):
90 shortcut = l
91 l = Conv2D('conv1', l, ch_out, 1, activation=BNReLU)
92 l = Conv2D('conv2', l, ch_out, 3, strides=stride, activation=BNReLU)
93 l = Conv2D('conv3', l, ch_out * 4, 1, activation=get_bn(zero_init=True))
94
95 squeeze = GlobalAvgPooling('gap', l)
96 squeeze = FullyConnected('fc1', squeeze, ch_out // 4, activation=tf.nn.relu)
97 squeeze = FullyConnected('fc2', squeeze, ch_out * 4, activation=tf.nn.sigmoid)
98 data_format = get_arg_scope()['Conv2D']['data_format']
99 ch_ax = 1 if data_format in ['NCHW', 'channels_first'] else 3
100 shape = [-1, 1, 1, 1]
101 shape[ch_ax] = ch_out * 4
102 l = l * tf.reshape(squeeze, shape)
103 out = l + resnet_shortcut(shortcut, ch_out * 4, stride, activation=get_bn(zero_init=False))
104 return tf.nn.relu(out)
105
106
107def resnext32x4d_bottleneck(l, ch_out, stride):

Callers

nothing calls this directly

Calls 6

Conv2DFunction · 0.90
GlobalAvgPoolingFunction · 0.90
FullyConnectedFunction · 0.90
get_arg_scopeFunction · 0.90
get_bnFunction · 0.70
resnet_shortcutFunction · 0.70

Tested by

no test coverage detected