MCPcopy Create free account
hub / github.com/tensorpack/tensorpack / resnet_bottleneck

Function resnet_bottleneck

examples/FasterRCNN/modeling/backbone.py:137–157  ·  view source on GitHub ↗
(l, ch_out, stride)

Source from the content-addressed store, hash-verified

135
136
137def resnet_bottleneck(l, ch_out, stride):
138 shortcut = l
139 if cfg.BACKBONE.STRIDE_1X1:
140 if stride == 2:
141 l = l[:, :, :-1, :-1]
142 l = Conv2D('conv1', l, ch_out, 1, strides=stride)
143 l = Conv2D('conv2', l, ch_out, 3, strides=1)
144 else:
145 l = Conv2D('conv1', l, ch_out, 1, strides=1)
146 if stride == 2:
147 l = tf.pad(l, [[0, 0], [0, 0], maybe_reverse_pad(0, 1), maybe_reverse_pad(0, 1)])
148 l = Conv2D('conv2', l, ch_out, 3, strides=2, padding='VALID')
149 else:
150 l = Conv2D('conv2', l, ch_out, 3, strides=stride)
151 if cfg.BACKBONE.NORM != 'None':
152 l = Conv2D('conv3', l, ch_out * 4, 1, activation=get_norm(zero_init=True))
153 else:
154 l = Conv2D('conv3', l, ch_out * 4, 1, activation=tf.identity,
155 kernel_initializer=tf.constant_initializer())
156 ret = l + resnet_shortcut(shortcut, ch_out * 4, stride, activation=get_norm(zero_init=False))
157 return tf.nn.relu(ret, name='output')
158
159
160def resnet_group(name, l, block_func, features, count, stride):

Callers

nothing calls this directly

Calls 4

Conv2DFunction · 0.90
maybe_reverse_padFunction · 0.85
get_normFunction · 0.85
resnet_shortcutFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…