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

Method resblock

examples/DoReFa-Net/resnet-dorefa.py:59–80  ·  view source on GitHub ↗
(x, channel, stride)

Source from the content-addressed store, hash-verified

57 return fa(nonlin(x))
58
59 def resblock(x, channel, stride):
60 def get_stem_full(x):
61 return (LinearWrap(x)
62 .Conv2D('c3x3a', channel, 3)
63 .BatchNorm('stembn')
64 .apply(activate)
65 .Conv2D('c3x3b', channel, 3)())
66 channel_mismatch = channel != x.get_shape().as_list()[3]
67 if stride != 1 or channel_mismatch or 'pool1' in x.name:
68 # handling pool1 is to work around an architecture bug in our model
69 if stride != 1 or 'pool1' in x.name:
70 x = AvgPooling('pool', x, stride, stride)
71 x = BatchNorm('bn', x)
72 x = activate(x)
73 shortcut = Conv2D('shortcut', x, channel, 1)
74 stem = get_stem_full(x)
75 else:
76 shortcut = x
77 x = BatchNorm('bn', x)
78 x = activate(x)
79 stem = get_stem_full(x)
80 return shortcut + stem
81
82 def group(x, name, channel, nr_block, stride):
83 with tf.variable_scope(name + 'blk1'):

Callers

nothing calls this directly

Calls 3

AvgPoolingFunction · 0.85
Conv2DFunction · 0.85
BatchNormFunction · 0.50

Tested by

no test coverage detected