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

Function resnet_bottleneck

examples/ResNet/resnet_model.py:77–86  ·  view source on GitHub ↗

stride_first: original resnet put stride on first conv. fb.resnet.torch put stride on second conv.

(l, ch_out, stride, stride_first=False)

Source from the content-addressed store, hash-verified

75
76
77def resnet_bottleneck(l, ch_out, stride, stride_first=False):
78 """
79 stride_first: original resnet put stride on first conv. fb.resnet.torch put stride on second conv.
80 """
81 shortcut = l
82 l = Conv2D('conv1', l, ch_out, 1, strides=stride if stride_first else 1, activation=BNReLU)
83 l = Conv2D('conv2', l, ch_out, 3, strides=1 if stride_first else stride, activation=BNReLU)
84 l = Conv2D('conv3', l, ch_out * 4, 1, activation=get_bn(zero_init=True))
85 out = l + resnet_shortcut(shortcut, ch_out * 4, stride, activation=get_bn(zero_init=False))
86 return tf.nn.relu(out)
87
88
89def se_bottleneck(l, ch_out, stride):

Callers

nothing calls this directly

Calls 3

Conv2DFunction · 0.90
get_bnFunction · 0.70
resnet_shortcutFunction · 0.70

Tested by

no test coverage detected