00001
00002
00003
00004
00005
00006
00007
00008 import cPickle
00009 import mxnet as mx
00010 from utils.symbol import Symbol
00011 from operator_py.proposal import *
00012 from operator_py.proposal_target import *
00013 from operator_py.box_annotator_ohem import *
00014
00015
00016 class deform_conv_demo(Symbol):
00017
00018 def __init__(self):
00019 """
00020 Use __init__ to define parameter network needs
00021 """
00022 self.eps = 1e-5
00023 self.use_global_stats = True
00024 self.workspace = 512
00025 self.units = (3, 4, 23, 3)
00026 self.filter_list = [256, 512, 1024, 2048]
00027
00028 def get_resnet_v1_conv4(self, data):
00029 conv1 = mx.symbol.Convolution(name='conv1', data=data, num_filter=64, pad=(3, 3), kernel=(7, 7), stride=(2, 2),
00030 no_bias=True)
00031 bn_conv1 = mx.symbol.BatchNorm(name='bn_conv1', data=conv1, use_global_stats=True, fix_gamma=False, eps=self.eps)
00032 scale_conv1 = bn_conv1
00033 conv1_relu = mx.symbol.Activation(name='conv1_relu', data=scale_conv1, act_type='relu')
00034 pool1 = mx.symbol.Pooling(name='pool1', data=conv1_relu, pooling_convention='full', pad=(0, 0), kernel=(3, 3),
00035 stride=(2, 2), pool_type='max')
00036 res2a_branch1 = mx.symbol.Convolution(name='res2a_branch1', data=pool1, num_filter=256, pad=(0, 0), kernel=(1, 1),
00037 stride=(1, 1), no_bias=True)
00038 bn2a_branch1 = mx.symbol.BatchNorm(name='bn2a_branch1', data=res2a_branch1, use_global_stats=True, fix_gamma=False, eps=self.eps)
00039 scale2a_branch1 = bn2a_branch1
00040 res2a_branch2a = mx.symbol.Convolution(name='res2a_branch2a', data=pool1, num_filter=64, pad=(0, 0), kernel=(1, 1),
00041 stride=(1, 1), no_bias=True)
00042 bn2a_branch2a = mx.symbol.BatchNorm(name='bn2a_branch2a', data=res2a_branch2a, use_global_stats=True,
00043 fix_gamma=False, eps=self.eps)
00044 scale2a_branch2a = bn2a_branch2a
00045 res2a_branch2a_relu = mx.symbol.Activation(name='res2a_branch2a_relu', data=scale2a_branch2a, act_type='relu')
00046 res2a_branch2b = mx.symbol.Convolution(name='res2a_branch2b', data=res2a_branch2a_relu, num_filter=64, pad=(1, 1),
00047 kernel=(3, 3), stride=(1, 1), no_bias=True)
00048 bn2a_branch2b = mx.symbol.BatchNorm(name='bn2a_branch2b', data=res2a_branch2b, use_global_stats=True,
00049 fix_gamma=False, eps=self.eps)
00050 scale2a_branch2b = bn2a_branch2b
00051 res2a_branch2b_relu = mx.symbol.Activation(name='res2a_branch2b_relu', data=scale2a_branch2b, act_type='relu')
00052 res2a_branch2c = mx.symbol.Convolution(name='res2a_branch2c', data=res2a_branch2b_relu, num_filter=256, pad=(0, 0),
00053 kernel=(1, 1), stride=(1, 1), no_bias=True)
00054 bn2a_branch2c = mx.symbol.BatchNorm(name='bn2a_branch2c', data=res2a_branch2c, use_global_stats=True,
00055 fix_gamma=False, eps=self.eps)
00056 scale2a_branch2c = bn2a_branch2c
00057 res2a = mx.symbol.broadcast_add(name='res2a', *[scale2a_branch1, scale2a_branch2c])
00058 res2a_relu = mx.symbol.Activation(name='res2a_relu', data=res2a, act_type='relu')
00059 res2b_branch2a = mx.symbol.Convolution(name='res2b_branch2a', data=res2a_relu, num_filter=64, pad=(0, 0),
00060 kernel=(1, 1), stride=(1, 1), no_bias=True)
00061 bn2b_branch2a = mx.symbol.BatchNorm(name='bn2b_branch2a', data=res2b_branch2a, use_global_stats=True,
00062 fix_gamma=False, eps=self.eps)
00063 scale2b_branch2a = bn2b_branch2a
00064 res2b_branch2a_relu = mx.symbol.Activation(name='res2b_branch2a_relu', data=scale2b_branch2a, act_type='relu')
00065 res2b_branch2b = mx.symbol.Convolution(name='res2b_branch2b', data=res2b_branch2a_relu, num_filter=64, pad=(1, 1),
00066 kernel=(3, 3), stride=(1, 1), no_bias=True)
00067 bn2b_branch2b = mx.symbol.BatchNorm(name='bn2b_branch2b', data=res2b_branch2b, use_global_stats=True,
00068 fix_gamma=False, eps=self.eps)
00069 scale2b_branch2b = bn2b_branch2b
00070 res2b_branch2b_relu = mx.symbol.Activation(name='res2b_branch2b_relu', data=scale2b_branch2b, act_type='relu')
00071 res2b_branch2c = mx.symbol.Convolution(name='res2b_branch2c', data=res2b_branch2b_relu, num_filter=256, pad=(0, 0),
00072 kernel=(1, 1), stride=(1, 1), no_bias=True)
00073 bn2b_branch2c = mx.symbol.BatchNorm(name='bn2b_branch2c', data=res2b_branch2c, use_global_stats=True,
00074 fix_gamma=False, eps=self.eps)
00075 scale2b_branch2c = bn2b_branch2c
00076 res2b = mx.symbol.broadcast_add(name='res2b', *[res2a_relu, scale2b_branch2c])
00077 res2b_relu = mx.symbol.Activation(name='res2b_relu', data=res2b, act_type='relu')
00078 res2c_branch2a = mx.symbol.Convolution(name='res2c_branch2a', data=res2b_relu, num_filter=64, pad=(0, 0),
00079 kernel=(1, 1), stride=(1, 1), no_bias=True)
00080 bn2c_branch2a = mx.symbol.BatchNorm(name='bn2c_branch2a', data=res2c_branch2a, use_global_stats=True,
00081 fix_gamma=False, eps=self.eps)
00082 scale2c_branch2a = bn2c_branch2a
00083 res2c_branch2a_relu = mx.symbol.Activation(name='res2c_branch2a_relu', data=scale2c_branch2a, act_type='relu')
00084 res2c_branch2b = mx.symbol.Convolution(name='res2c_branch2b', data=res2c_branch2a_relu, num_filter=64, pad=(1, 1),
00085 kernel=(3, 3), stride=(1, 1), no_bias=True)
00086 bn2c_branch2b = mx.symbol.BatchNorm(name='bn2c_branch2b', data=res2c_branch2b, use_global_stats=True,
00087 fix_gamma=False, eps=self.eps)
00088 scale2c_branch2b = bn2c_branch2b
00089 res2c_branch2b_relu = mx.symbol.Activation(name='res2c_branch2b_relu', data=scale2c_branch2b, act_type='relu')
00090 res2c_branch2c = mx.symbol.Convolution(name='res2c_branch2c', data=res2c_branch2b_relu, num_filter=256, pad=(0, 0),
00091 kernel=(1, 1), stride=(1, 1), no_bias=True)
00092 bn2c_branch2c = mx.symbol.BatchNorm(name='bn2c_branch2c', data=res2c_branch2c, use_global_stats=True,
00093 fix_gamma=False, eps=self.eps)
00094 scale2c_branch2c = bn2c_branch2c
00095 res2c = mx.symbol.broadcast_add(name='res2c', *[res2b_relu, scale2c_branch2c])
00096 res2c_relu = mx.symbol.Activation(name='res2c_relu', data=res2c, act_type='relu')
00097 res3a_branch1 = mx.symbol.Convolution(name='res3a_branch1', data=res2c_relu, num_filter=512, pad=(0, 0),
00098 kernel=(1, 1), stride=(2, 2), no_bias=True)
00099 bn3a_branch1 = mx.symbol.BatchNorm(name='bn3a_branch1', data=res3a_branch1, use_global_stats=True, fix_gamma=False, eps=self.eps)
00100 scale3a_branch1 = bn3a_branch1
00101 res3a_branch2a = mx.symbol.Convolution(name='res3a_branch2a', data=res2c_relu, num_filter=128, pad=(0, 0),
00102 kernel=(1, 1), stride=(2, 2), no_bias=True)
00103 bn3a_branch2a = mx.symbol.BatchNorm(name='bn3a_branch2a', data=res3a_branch2a, use_global_stats=True,
00104 fix_gamma=False, eps=self.eps)
00105 scale3a_branch2a = bn3a_branch2a
00106 res3a_branch2a_relu = mx.symbol.Activation(name='res3a_branch2a_relu', data=scale3a_branch2a, act_type='relu')
00107 res3a_branch2b = mx.symbol.Convolution(name='res3a_branch2b', data=res3a_branch2a_relu, num_filter=128, pad=(1, 1),
00108 kernel=(3, 3), stride=(1, 1), no_bias=True)
00109 bn3a_branch2b = mx.symbol.BatchNorm(name='bn3a_branch2b', data=res3a_branch2b, use_global_stats=True,
00110 fix_gamma=False, eps=self.eps)
00111 scale3a_branch2b = bn3a_branch2b
00112 res3a_branch2b_relu = mx.symbol.Activation(name='res3a_branch2b_relu', data=scale3a_branch2b, act_type='relu')
00113 res3a_branch2c = mx.symbol.Convolution(name='res3a_branch2c', data=res3a_branch2b_relu, num_filter=512, pad=(0, 0),
00114 kernel=(1, 1), stride=(1, 1), no_bias=True)
00115 bn3a_branch2c = mx.symbol.BatchNorm(name='bn3a_branch2c', data=res3a_branch2c, use_global_stats=True,
00116 fix_gamma=False, eps=self.eps)
00117 scale3a_branch2c = bn3a_branch2c
00118 res3a = mx.symbol.broadcast_add(name='res3a', *[scale3a_branch1, scale3a_branch2c])
00119 res3a_relu = mx.symbol.Activation(name='res3a_relu', data=res3a, act_type='relu')
00120 res3b1_branch2a = mx.symbol.Convolution(name='res3b1_branch2a', data=res3a_relu, num_filter=128, pad=(0, 0),
00121 kernel=(1, 1), stride=(1, 1), no_bias=True)
00122 bn3b1_branch2a = mx.symbol.BatchNorm(name='bn3b1_branch2a', data=res3b1_branch2a, use_global_stats=True,
00123 fix_gamma=False, eps=self.eps)
00124 scale3b1_branch2a = bn3b1_branch2a
00125 res3b1_branch2a_relu = mx.symbol.Activation(name='res3b1_branch2a_relu', data=scale3b1_branch2a, act_type='relu')
00126 res3b1_branch2b = mx.symbol.Convolution(name='res3b1_branch2b', data=res3b1_branch2a_relu, num_filter=128,
00127 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00128 bn3b1_branch2b = mx.symbol.BatchNorm(name='bn3b1_branch2b', data=res3b1_branch2b, use_global_stats=True,
00129 fix_gamma=False, eps=self.eps)
00130 scale3b1_branch2b = bn3b1_branch2b
00131 res3b1_branch2b_relu = mx.symbol.Activation(name='res3b1_branch2b_relu', data=scale3b1_branch2b, act_type='relu')
00132 res3b1_branch2c = mx.symbol.Convolution(name='res3b1_branch2c', data=res3b1_branch2b_relu, num_filter=512,
00133 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00134 bn3b1_branch2c = mx.symbol.BatchNorm(name='bn3b1_branch2c', data=res3b1_branch2c, use_global_stats=True,
00135 fix_gamma=False, eps=self.eps)
00136 scale3b1_branch2c = bn3b1_branch2c
00137 res3b1 = mx.symbol.broadcast_add(name='res3b1', *[res3a_relu, scale3b1_branch2c])
00138 res3b1_relu = mx.symbol.Activation(name='res3b1_relu', data=res3b1, act_type='relu')
00139 res3b2_branch2a = mx.symbol.Convolution(name='res3b2_branch2a', data=res3b1_relu, num_filter=128, pad=(0, 0),
00140 kernel=(1, 1), stride=(1, 1), no_bias=True)
00141 bn3b2_branch2a = mx.symbol.BatchNorm(name='bn3b2_branch2a', data=res3b2_branch2a, use_global_stats=True,
00142 fix_gamma=False, eps=self.eps)
00143 scale3b2_branch2a = bn3b2_branch2a
00144 res3b2_branch2a_relu = mx.symbol.Activation(name='res3b2_branch2a_relu', data=scale3b2_branch2a, act_type='relu')
00145 res3b2_branch2b = mx.symbol.Convolution(name='res3b2_branch2b', data=res3b2_branch2a_relu, num_filter=128,
00146 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00147 bn3b2_branch2b = mx.symbol.BatchNorm(name='bn3b2_branch2b', data=res3b2_branch2b, use_global_stats=True,
00148 fix_gamma=False, eps=self.eps)
00149 scale3b2_branch2b = bn3b2_branch2b
00150 res3b2_branch2b_relu = mx.symbol.Activation(name='res3b2_branch2b_relu', data=scale3b2_branch2b, act_type='relu')
00151 res3b2_branch2c = mx.symbol.Convolution(name='res3b2_branch2c', data=res3b2_branch2b_relu, num_filter=512,
00152 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00153 bn3b2_branch2c = mx.symbol.BatchNorm(name='bn3b2_branch2c', data=res3b2_branch2c, use_global_stats=True,
00154 fix_gamma=False, eps=self.eps)
00155 scale3b2_branch2c = bn3b2_branch2c
00156 res3b2 = mx.symbol.broadcast_add(name='res3b2', *[res3b1_relu, scale3b2_branch2c])
00157 res3b2_relu = mx.symbol.Activation(name='res3b2_relu', data=res3b2, act_type='relu')
00158 res3b3_branch2a = mx.symbol.Convolution(name='res3b3_branch2a', data=res3b2_relu, num_filter=128, pad=(0, 0),
00159 kernel=(1, 1), stride=(1, 1), no_bias=True)
00160 bn3b3_branch2a = mx.symbol.BatchNorm(name='bn3b3_branch2a', data=res3b3_branch2a, use_global_stats=True,
00161 fix_gamma=False, eps=self.eps)
00162 scale3b3_branch2a = bn3b3_branch2a
00163 res3b3_branch2a_relu = mx.symbol.Activation(name='res3b3_branch2a_relu', data=scale3b3_branch2a, act_type='relu')
00164 res3b3_branch2b = mx.symbol.Convolution(name='res3b3_branch2b', data=res3b3_branch2a_relu, num_filter=128,
00165 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00166 bn3b3_branch2b = mx.symbol.BatchNorm(name='bn3b3_branch2b', data=res3b3_branch2b, use_global_stats=True,
00167 fix_gamma=False, eps=self.eps)
00168 scale3b3_branch2b = bn3b3_branch2b
00169 res3b3_branch2b_relu = mx.symbol.Activation(name='res3b3_branch2b_relu', data=scale3b3_branch2b, act_type='relu')
00170 res3b3_branch2c = mx.symbol.Convolution(name='res3b3_branch2c', data=res3b3_branch2b_relu, num_filter=512,
00171 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00172 bn3b3_branch2c = mx.symbol.BatchNorm(name='bn3b3_branch2c', data=res3b3_branch2c, use_global_stats=True,
00173 fix_gamma=False, eps=self.eps)
00174 scale3b3_branch2c = bn3b3_branch2c
00175 res3b3 = mx.symbol.broadcast_add(name='res3b3', *[res3b2_relu, scale3b3_branch2c])
00176 res3b3_relu = mx.symbol.Activation(name='res3b3_relu', data=res3b3, act_type='relu')
00177 res4a_branch1 = mx.symbol.Convolution(name='res4a_branch1', data=res3b3_relu, num_filter=1024, pad=(0, 0),
00178 kernel=(1, 1), stride=(2, 2), no_bias=True)
00179 bn4a_branch1 = mx.symbol.BatchNorm(name='bn4a_branch1', data=res4a_branch1, use_global_stats=True, fix_gamma=False, eps=self.eps)
00180 scale4a_branch1 = bn4a_branch1
00181 res4a_branch2a = mx.symbol.Convolution(name='res4a_branch2a', data=res3b3_relu, num_filter=256, pad=(0, 0),
00182 kernel=(1, 1), stride=(2, 2), no_bias=True)
00183 bn4a_branch2a = mx.symbol.BatchNorm(name='bn4a_branch2a', data=res4a_branch2a, use_global_stats=True,
00184 fix_gamma=False, eps=self.eps)
00185 scale4a_branch2a = bn4a_branch2a
00186 res4a_branch2a_relu = mx.symbol.Activation(name='res4a_branch2a_relu', data=scale4a_branch2a, act_type='relu')
00187 res4a_branch2b = mx.symbol.Convolution(name='res4a_branch2b', data=res4a_branch2a_relu, num_filter=256, pad=(1, 1),
00188 kernel=(3, 3), stride=(1, 1), no_bias=True)
00189 bn4a_branch2b = mx.symbol.BatchNorm(name='bn4a_branch2b', data=res4a_branch2b, use_global_stats=True,
00190 fix_gamma=False, eps=self.eps)
00191 scale4a_branch2b = bn4a_branch2b
00192 res4a_branch2b_relu = mx.symbol.Activation(name='res4a_branch2b_relu', data=scale4a_branch2b, act_type='relu')
00193 res4a_branch2c = mx.symbol.Convolution(name='res4a_branch2c', data=res4a_branch2b_relu, num_filter=1024, pad=(0, 0),
00194 kernel=(1, 1), stride=(1, 1), no_bias=True)
00195 bn4a_branch2c = mx.symbol.BatchNorm(name='bn4a_branch2c', data=res4a_branch2c, use_global_stats=True,
00196 fix_gamma=False, eps=self.eps)
00197 scale4a_branch2c = bn4a_branch2c
00198 res4a = mx.symbol.broadcast_add(name='res4a', *[scale4a_branch1, scale4a_branch2c])
00199 res4a_relu = mx.symbol.Activation(name='res4a_relu', data=res4a, act_type='relu')
00200 res4b1_branch2a = mx.symbol.Convolution(name='res4b1_branch2a', data=res4a_relu, num_filter=256, pad=(0, 0),
00201 kernel=(1, 1), stride=(1, 1), no_bias=True)
00202 bn4b1_branch2a = mx.symbol.BatchNorm(name='bn4b1_branch2a', data=res4b1_branch2a, use_global_stats=True,
00203 fix_gamma=False, eps=self.eps)
00204 scale4b1_branch2a = bn4b1_branch2a
00205 res4b1_branch2a_relu = mx.symbol.Activation(name='res4b1_branch2a_relu', data=scale4b1_branch2a, act_type='relu')
00206 res4b1_branch2b = mx.symbol.Convolution(name='res4b1_branch2b', data=res4b1_branch2a_relu, num_filter=256,
00207 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00208 bn4b1_branch2b = mx.symbol.BatchNorm(name='bn4b1_branch2b', data=res4b1_branch2b, use_global_stats=True,
00209 fix_gamma=False, eps=self.eps)
00210 scale4b1_branch2b = bn4b1_branch2b
00211 res4b1_branch2b_relu = mx.symbol.Activation(name='res4b1_branch2b_relu', data=scale4b1_branch2b, act_type='relu')
00212 res4b1_branch2c = mx.symbol.Convolution(name='res4b1_branch2c', data=res4b1_branch2b_relu, num_filter=1024,
00213 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00214 bn4b1_branch2c = mx.symbol.BatchNorm(name='bn4b1_branch2c', data=res4b1_branch2c, use_global_stats=True,
00215 fix_gamma=False, eps=self.eps)
00216 scale4b1_branch2c = bn4b1_branch2c
00217 res4b1 = mx.symbol.broadcast_add(name='res4b1', *[res4a_relu, scale4b1_branch2c])
00218 res4b1_relu = mx.symbol.Activation(name='res4b1_relu', data=res4b1, act_type='relu')
00219 res4b2_branch2a = mx.symbol.Convolution(name='res4b2_branch2a', data=res4b1_relu, num_filter=256, pad=(0, 0),
00220 kernel=(1, 1), stride=(1, 1), no_bias=True)
00221 bn4b2_branch2a = mx.symbol.BatchNorm(name='bn4b2_branch2a', data=res4b2_branch2a, use_global_stats=True,
00222 fix_gamma=False, eps=self.eps)
00223 scale4b2_branch2a = bn4b2_branch2a
00224 res4b2_branch2a_relu = mx.symbol.Activation(name='res4b2_branch2a_relu', data=scale4b2_branch2a, act_type='relu')
00225 res4b2_branch2b = mx.symbol.Convolution(name='res4b2_branch2b', data=res4b2_branch2a_relu, num_filter=256,
00226 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00227 bn4b2_branch2b = mx.symbol.BatchNorm(name='bn4b2_branch2b', data=res4b2_branch2b, use_global_stats=True,
00228 fix_gamma=False, eps=self.eps)
00229 scale4b2_branch2b = bn4b2_branch2b
00230 res4b2_branch2b_relu = mx.symbol.Activation(name='res4b2_branch2b_relu', data=scale4b2_branch2b, act_type='relu')
00231 res4b2_branch2c = mx.symbol.Convolution(name='res4b2_branch2c', data=res4b2_branch2b_relu, num_filter=1024,
00232 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00233 bn4b2_branch2c = mx.symbol.BatchNorm(name='bn4b2_branch2c', data=res4b2_branch2c, use_global_stats=True,
00234 fix_gamma=False, eps=self.eps)
00235 scale4b2_branch2c = bn4b2_branch2c
00236 res4b2 = mx.symbol.broadcast_add(name='res4b2', *[res4b1_relu, scale4b2_branch2c])
00237 res4b2_relu = mx.symbol.Activation(name='res4b2_relu', data=res4b2, act_type='relu')
00238 res4b3_branch2a = mx.symbol.Convolution(name='res4b3_branch2a', data=res4b2_relu, num_filter=256, pad=(0, 0),
00239 kernel=(1, 1), stride=(1, 1), no_bias=True)
00240 bn4b3_branch2a = mx.symbol.BatchNorm(name='bn4b3_branch2a', data=res4b3_branch2a, use_global_stats=True,
00241 fix_gamma=False, eps=self.eps)
00242 scale4b3_branch2a = bn4b3_branch2a
00243 res4b3_branch2a_relu = mx.symbol.Activation(name='res4b3_branch2a_relu', data=scale4b3_branch2a, act_type='relu')
00244 res4b3_branch2b = mx.symbol.Convolution(name='res4b3_branch2b', data=res4b3_branch2a_relu, num_filter=256,
00245 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00246 bn4b3_branch2b = mx.symbol.BatchNorm(name='bn4b3_branch2b', data=res4b3_branch2b, use_global_stats=True,
00247 fix_gamma=False, eps=self.eps)
00248 scale4b3_branch2b = bn4b3_branch2b
00249 res4b3_branch2b_relu = mx.symbol.Activation(name='res4b3_branch2b_relu', data=scale4b3_branch2b, act_type='relu')
00250 res4b3_branch2c = mx.symbol.Convolution(name='res4b3_branch2c', data=res4b3_branch2b_relu, num_filter=1024,
00251 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00252 bn4b3_branch2c = mx.symbol.BatchNorm(name='bn4b3_branch2c', data=res4b3_branch2c, use_global_stats=True,
00253 fix_gamma=False, eps=self.eps)
00254 scale4b3_branch2c = bn4b3_branch2c
00255 res4b3 = mx.symbol.broadcast_add(name='res4b3', *[res4b2_relu, scale4b3_branch2c])
00256 res4b3_relu = mx.symbol.Activation(name='res4b3_relu', data=res4b3, act_type='relu')
00257 res4b4_branch2a = mx.symbol.Convolution(name='res4b4_branch2a', data=res4b3_relu, num_filter=256, pad=(0, 0),
00258 kernel=(1, 1), stride=(1, 1), no_bias=True)
00259 bn4b4_branch2a = mx.symbol.BatchNorm(name='bn4b4_branch2a', data=res4b4_branch2a, use_global_stats=True,
00260 fix_gamma=False, eps=self.eps)
00261 scale4b4_branch2a = bn4b4_branch2a
00262 res4b4_branch2a_relu = mx.symbol.Activation(name='res4b4_branch2a_relu', data=scale4b4_branch2a, act_type='relu')
00263 res4b4_branch2b = mx.symbol.Convolution(name='res4b4_branch2b', data=res4b4_branch2a_relu, num_filter=256,
00264 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00265 bn4b4_branch2b = mx.symbol.BatchNorm(name='bn4b4_branch2b', data=res4b4_branch2b, use_global_stats=True,
00266 fix_gamma=False, eps=self.eps)
00267 scale4b4_branch2b = bn4b4_branch2b
00268 res4b4_branch2b_relu = mx.symbol.Activation(name='res4b4_branch2b_relu', data=scale4b4_branch2b, act_type='relu')
00269 res4b4_branch2c = mx.symbol.Convolution(name='res4b4_branch2c', data=res4b4_branch2b_relu, num_filter=1024,
00270 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00271 bn4b4_branch2c = mx.symbol.BatchNorm(name='bn4b4_branch2c', data=res4b4_branch2c, use_global_stats=True,
00272 fix_gamma=False, eps=self.eps)
00273 scale4b4_branch2c = bn4b4_branch2c
00274 res4b4 = mx.symbol.broadcast_add(name='res4b4', *[res4b3_relu, scale4b4_branch2c])
00275 res4b4_relu = mx.symbol.Activation(name='res4b4_relu', data=res4b4, act_type='relu')
00276 res4b5_branch2a = mx.symbol.Convolution(name='res4b5_branch2a', data=res4b4_relu, num_filter=256, pad=(0, 0),
00277 kernel=(1, 1), stride=(1, 1), no_bias=True)
00278 bn4b5_branch2a = mx.symbol.BatchNorm(name='bn4b5_branch2a', data=res4b5_branch2a, use_global_stats=True,
00279 fix_gamma=False, eps=self.eps)
00280 scale4b5_branch2a = bn4b5_branch2a
00281 res4b5_branch2a_relu = mx.symbol.Activation(name='res4b5_branch2a_relu', data=scale4b5_branch2a, act_type='relu')
00282 res4b5_branch2b = mx.symbol.Convolution(name='res4b5_branch2b', data=res4b5_branch2a_relu, num_filter=256,
00283 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00284 bn4b5_branch2b = mx.symbol.BatchNorm(name='bn4b5_branch2b', data=res4b5_branch2b, use_global_stats=True,
00285 fix_gamma=False, eps=self.eps)
00286 scale4b5_branch2b = bn4b5_branch2b
00287 res4b5_branch2b_relu = mx.symbol.Activation(name='res4b5_branch2b_relu', data=scale4b5_branch2b, act_type='relu')
00288 res4b5_branch2c = mx.symbol.Convolution(name='res4b5_branch2c', data=res4b5_branch2b_relu, num_filter=1024,
00289 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00290 bn4b5_branch2c = mx.symbol.BatchNorm(name='bn4b5_branch2c', data=res4b5_branch2c, use_global_stats=True,
00291 fix_gamma=False, eps=self.eps)
00292 scale4b5_branch2c = bn4b5_branch2c
00293 res4b5 = mx.symbol.broadcast_add(name='res4b5', *[res4b4_relu, scale4b5_branch2c])
00294 res4b5_relu = mx.symbol.Activation(name='res4b5_relu', data=res4b5, act_type='relu')
00295 res4b6_branch2a = mx.symbol.Convolution(name='res4b6_branch2a', data=res4b5_relu, num_filter=256, pad=(0, 0),
00296 kernel=(1, 1), stride=(1, 1), no_bias=True)
00297 bn4b6_branch2a = mx.symbol.BatchNorm(name='bn4b6_branch2a', data=res4b6_branch2a, use_global_stats=True,
00298 fix_gamma=False, eps=self.eps)
00299 scale4b6_branch2a = bn4b6_branch2a
00300 res4b6_branch2a_relu = mx.symbol.Activation(name='res4b6_branch2a_relu', data=scale4b6_branch2a, act_type='relu')
00301 res4b6_branch2b = mx.symbol.Convolution(name='res4b6_branch2b', data=res4b6_branch2a_relu, num_filter=256,
00302 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00303 bn4b6_branch2b = mx.symbol.BatchNorm(name='bn4b6_branch2b', data=res4b6_branch2b, use_global_stats=True,
00304 fix_gamma=False, eps=self.eps)
00305 scale4b6_branch2b = bn4b6_branch2b
00306 res4b6_branch2b_relu = mx.symbol.Activation(name='res4b6_branch2b_relu', data=scale4b6_branch2b, act_type='relu')
00307 res4b6_branch2c = mx.symbol.Convolution(name='res4b6_branch2c', data=res4b6_branch2b_relu, num_filter=1024,
00308 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00309 bn4b6_branch2c = mx.symbol.BatchNorm(name='bn4b6_branch2c', data=res4b6_branch2c, use_global_stats=True,
00310 fix_gamma=False, eps=self.eps)
00311 scale4b6_branch2c = bn4b6_branch2c
00312 res4b6 = mx.symbol.broadcast_add(name='res4b6', *[res4b5_relu, scale4b6_branch2c])
00313 res4b6_relu = mx.symbol.Activation(name='res4b6_relu', data=res4b6, act_type='relu')
00314 res4b7_branch2a = mx.symbol.Convolution(name='res4b7_branch2a', data=res4b6_relu, num_filter=256, pad=(0, 0),
00315 kernel=(1, 1), stride=(1, 1), no_bias=True)
00316 bn4b7_branch2a = mx.symbol.BatchNorm(name='bn4b7_branch2a', data=res4b7_branch2a, use_global_stats=True,
00317 fix_gamma=False, eps=self.eps)
00318 scale4b7_branch2a = bn4b7_branch2a
00319 res4b7_branch2a_relu = mx.symbol.Activation(name='res4b7_branch2a_relu', data=scale4b7_branch2a, act_type='relu')
00320 res4b7_branch2b = mx.symbol.Convolution(name='res4b7_branch2b', data=res4b7_branch2a_relu, num_filter=256,
00321 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00322 bn4b7_branch2b = mx.symbol.BatchNorm(name='bn4b7_branch2b', data=res4b7_branch2b, use_global_stats=True,
00323 fix_gamma=False, eps=self.eps)
00324 scale4b7_branch2b = bn4b7_branch2b
00325 res4b7_branch2b_relu = mx.symbol.Activation(name='res4b7_branch2b_relu', data=scale4b7_branch2b, act_type='relu')
00326 res4b7_branch2c = mx.symbol.Convolution(name='res4b7_branch2c', data=res4b7_branch2b_relu, num_filter=1024,
00327 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00328 bn4b7_branch2c = mx.symbol.BatchNorm(name='bn4b7_branch2c', data=res4b7_branch2c, use_global_stats=True,
00329 fix_gamma=False, eps=self.eps)
00330 scale4b7_branch2c = bn4b7_branch2c
00331 res4b7 = mx.symbol.broadcast_add(name='res4b7', *[res4b6_relu, scale4b7_branch2c])
00332 res4b7_relu = mx.symbol.Activation(name='res4b7_relu', data=res4b7, act_type='relu')
00333 res4b8_branch2a = mx.symbol.Convolution(name='res4b8_branch2a', data=res4b7_relu, num_filter=256, pad=(0, 0),
00334 kernel=(1, 1), stride=(1, 1), no_bias=True)
00335 bn4b8_branch2a = mx.symbol.BatchNorm(name='bn4b8_branch2a', data=res4b8_branch2a, use_global_stats=True,
00336 fix_gamma=False, eps=self.eps)
00337 scale4b8_branch2a = bn4b8_branch2a
00338 res4b8_branch2a_relu = mx.symbol.Activation(name='res4b8_branch2a_relu', data=scale4b8_branch2a, act_type='relu')
00339 res4b8_branch2b = mx.symbol.Convolution(name='res4b8_branch2b', data=res4b8_branch2a_relu, num_filter=256,
00340 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00341 bn4b8_branch2b = mx.symbol.BatchNorm(name='bn4b8_branch2b', data=res4b8_branch2b, use_global_stats=True,
00342 fix_gamma=False, eps=self.eps)
00343 scale4b8_branch2b = bn4b8_branch2b
00344 res4b8_branch2b_relu = mx.symbol.Activation(name='res4b8_branch2b_relu', data=scale4b8_branch2b, act_type='relu')
00345 res4b8_branch2c = mx.symbol.Convolution(name='res4b8_branch2c', data=res4b8_branch2b_relu, num_filter=1024,
00346 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00347 bn4b8_branch2c = mx.symbol.BatchNorm(name='bn4b8_branch2c', data=res4b8_branch2c, use_global_stats=True,
00348 fix_gamma=False, eps=self.eps)
00349 scale4b8_branch2c = bn4b8_branch2c
00350 res4b8 = mx.symbol.broadcast_add(name='res4b8', *[res4b7_relu, scale4b8_branch2c])
00351 res4b8_relu = mx.symbol.Activation(name='res4b8_relu', data=res4b8, act_type='relu')
00352 res4b9_branch2a = mx.symbol.Convolution(name='res4b9_branch2a', data=res4b8_relu, num_filter=256, pad=(0, 0),
00353 kernel=(1, 1), stride=(1, 1), no_bias=True)
00354 bn4b9_branch2a = mx.symbol.BatchNorm(name='bn4b9_branch2a', data=res4b9_branch2a, use_global_stats=True,
00355 fix_gamma=False, eps=self.eps)
00356 scale4b9_branch2a = bn4b9_branch2a
00357 res4b9_branch2a_relu = mx.symbol.Activation(name='res4b9_branch2a_relu', data=scale4b9_branch2a, act_type='relu')
00358 res4b9_branch2b = mx.symbol.Convolution(name='res4b9_branch2b', data=res4b9_branch2a_relu, num_filter=256,
00359 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00360 bn4b9_branch2b = mx.symbol.BatchNorm(name='bn4b9_branch2b', data=res4b9_branch2b, use_global_stats=True,
00361 fix_gamma=False, eps=self.eps)
00362 scale4b9_branch2b = bn4b9_branch2b
00363 res4b9_branch2b_relu = mx.symbol.Activation(name='res4b9_branch2b_relu', data=scale4b9_branch2b, act_type='relu')
00364 res4b9_branch2c = mx.symbol.Convolution(name='res4b9_branch2c', data=res4b9_branch2b_relu, num_filter=1024,
00365 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00366 bn4b9_branch2c = mx.symbol.BatchNorm(name='bn4b9_branch2c', data=res4b9_branch2c, use_global_stats=True,
00367 fix_gamma=False, eps=self.eps)
00368 scale4b9_branch2c = bn4b9_branch2c
00369 res4b9 = mx.symbol.broadcast_add(name='res4b9', *[res4b8_relu, scale4b9_branch2c])
00370 res4b9_relu = mx.symbol.Activation(name='res4b9_relu', data=res4b9, act_type='relu')
00371 res4b10_branch2a = mx.symbol.Convolution(name='res4b10_branch2a', data=res4b9_relu, num_filter=256, pad=(0, 0),
00372 kernel=(1, 1), stride=(1, 1), no_bias=True)
00373 bn4b10_branch2a = mx.symbol.BatchNorm(name='bn4b10_branch2a', data=res4b10_branch2a, use_global_stats=True,
00374 fix_gamma=False, eps=self.eps)
00375 scale4b10_branch2a = bn4b10_branch2a
00376 res4b10_branch2a_relu = mx.symbol.Activation(name='res4b10_branch2a_relu', data=scale4b10_branch2a, act_type='relu')
00377 res4b10_branch2b = mx.symbol.Convolution(name='res4b10_branch2b', data=res4b10_branch2a_relu, num_filter=256,
00378 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00379 bn4b10_branch2b = mx.symbol.BatchNorm(name='bn4b10_branch2b', data=res4b10_branch2b, use_global_stats=True,
00380 fix_gamma=False, eps=self.eps)
00381 scale4b10_branch2b = bn4b10_branch2b
00382 res4b10_branch2b_relu = mx.symbol.Activation(name='res4b10_branch2b_relu', data=scale4b10_branch2b, act_type='relu')
00383 res4b10_branch2c = mx.symbol.Convolution(name='res4b10_branch2c', data=res4b10_branch2b_relu, num_filter=1024,
00384 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00385 bn4b10_branch2c = mx.symbol.BatchNorm(name='bn4b10_branch2c', data=res4b10_branch2c, use_global_stats=True,
00386 fix_gamma=False, eps=self.eps)
00387 scale4b10_branch2c = bn4b10_branch2c
00388 res4b10 = mx.symbol.broadcast_add(name='res4b10', *[res4b9_relu, scale4b10_branch2c])
00389 res4b10_relu = mx.symbol.Activation(name='res4b10_relu', data=res4b10, act_type='relu')
00390 res4b11_branch2a = mx.symbol.Convolution(name='res4b11_branch2a', data=res4b10_relu, num_filter=256, pad=(0, 0),
00391 kernel=(1, 1), stride=(1, 1), no_bias=True)
00392 bn4b11_branch2a = mx.symbol.BatchNorm(name='bn4b11_branch2a', data=res4b11_branch2a, use_global_stats=True,
00393 fix_gamma=False, eps=self.eps)
00394 scale4b11_branch2a = bn4b11_branch2a
00395 res4b11_branch2a_relu = mx.symbol.Activation(name='res4b11_branch2a_relu', data=scale4b11_branch2a, act_type='relu')
00396 res4b11_branch2b = mx.symbol.Convolution(name='res4b11_branch2b', data=res4b11_branch2a_relu, num_filter=256,
00397 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00398 bn4b11_branch2b = mx.symbol.BatchNorm(name='bn4b11_branch2b', data=res4b11_branch2b, use_global_stats=True,
00399 fix_gamma=False, eps=self.eps)
00400 scale4b11_branch2b = bn4b11_branch2b
00401 res4b11_branch2b_relu = mx.symbol.Activation(name='res4b11_branch2b_relu', data=scale4b11_branch2b, act_type='relu')
00402 res4b11_branch2c = mx.symbol.Convolution(name='res4b11_branch2c', data=res4b11_branch2b_relu, num_filter=1024,
00403 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00404 bn4b11_branch2c = mx.symbol.BatchNorm(name='bn4b11_branch2c', data=res4b11_branch2c, use_global_stats=True,
00405 fix_gamma=False, eps=self.eps)
00406 scale4b11_branch2c = bn4b11_branch2c
00407 res4b11 = mx.symbol.broadcast_add(name='res4b11', *[res4b10_relu, scale4b11_branch2c])
00408 res4b11_relu = mx.symbol.Activation(name='res4b11_relu', data=res4b11, act_type='relu')
00409 res4b12_branch2a = mx.symbol.Convolution(name='res4b12_branch2a', data=res4b11_relu, num_filter=256, pad=(0, 0),
00410 kernel=(1, 1), stride=(1, 1), no_bias=True)
00411 bn4b12_branch2a = mx.symbol.BatchNorm(name='bn4b12_branch2a', data=res4b12_branch2a, use_global_stats=True,
00412 fix_gamma=False, eps=self.eps)
00413 scale4b12_branch2a = bn4b12_branch2a
00414 res4b12_branch2a_relu = mx.symbol.Activation(name='res4b12_branch2a_relu', data=scale4b12_branch2a, act_type='relu')
00415 res4b12_branch2b = mx.symbol.Convolution(name='res4b12_branch2b', data=res4b12_branch2a_relu, num_filter=256,
00416 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00417 bn4b12_branch2b = mx.symbol.BatchNorm(name='bn4b12_branch2b', data=res4b12_branch2b, use_global_stats=True,
00418 fix_gamma=False, eps=self.eps)
00419 scale4b12_branch2b = bn4b12_branch2b
00420 res4b12_branch2b_relu = mx.symbol.Activation(name='res4b12_branch2b_relu', data=scale4b12_branch2b, act_type='relu')
00421 res4b12_branch2c = mx.symbol.Convolution(name='res4b12_branch2c', data=res4b12_branch2b_relu, num_filter=1024,
00422 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00423 bn4b12_branch2c = mx.symbol.BatchNorm(name='bn4b12_branch2c', data=res4b12_branch2c, use_global_stats=True,
00424 fix_gamma=False, eps=self.eps)
00425 scale4b12_branch2c = bn4b12_branch2c
00426 res4b12 = mx.symbol.broadcast_add(name='res4b12', *[res4b11_relu, scale4b12_branch2c])
00427 res4b12_relu = mx.symbol.Activation(name='res4b12_relu', data=res4b12, act_type='relu')
00428 res4b13_branch2a = mx.symbol.Convolution(name='res4b13_branch2a', data=res4b12_relu, num_filter=256, pad=(0, 0),
00429 kernel=(1, 1), stride=(1, 1), no_bias=True)
00430 bn4b13_branch2a = mx.symbol.BatchNorm(name='bn4b13_branch2a', data=res4b13_branch2a, use_global_stats=True,
00431 fix_gamma=False, eps=self.eps)
00432 scale4b13_branch2a = bn4b13_branch2a
00433 res4b13_branch2a_relu = mx.symbol.Activation(name='res4b13_branch2a_relu', data=scale4b13_branch2a, act_type='relu')
00434 res4b13_branch2b = mx.symbol.Convolution(name='res4b13_branch2b', data=res4b13_branch2a_relu, num_filter=256,
00435 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00436 bn4b13_branch2b = mx.symbol.BatchNorm(name='bn4b13_branch2b', data=res4b13_branch2b, use_global_stats=True,
00437 fix_gamma=False, eps=self.eps)
00438 scale4b13_branch2b = bn4b13_branch2b
00439 res4b13_branch2b_relu = mx.symbol.Activation(name='res4b13_branch2b_relu', data=scale4b13_branch2b, act_type='relu')
00440 res4b13_branch2c = mx.symbol.Convolution(name='res4b13_branch2c', data=res4b13_branch2b_relu, num_filter=1024,
00441 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00442 bn4b13_branch2c = mx.symbol.BatchNorm(name='bn4b13_branch2c', data=res4b13_branch2c, use_global_stats=True,
00443 fix_gamma=False, eps=self.eps)
00444 scale4b13_branch2c = bn4b13_branch2c
00445 res4b13 = mx.symbol.broadcast_add(name='res4b13', *[res4b12_relu, scale4b13_branch2c])
00446 res4b13_relu = mx.symbol.Activation(name='res4b13_relu', data=res4b13, act_type='relu')
00447 res4b14_branch2a = mx.symbol.Convolution(name='res4b14_branch2a', data=res4b13_relu, num_filter=256, pad=(0, 0),
00448 kernel=(1, 1), stride=(1, 1), no_bias=True)
00449 bn4b14_branch2a = mx.symbol.BatchNorm(name='bn4b14_branch2a', data=res4b14_branch2a, use_global_stats=True,
00450 fix_gamma=False, eps=self.eps)
00451 scale4b14_branch2a = bn4b14_branch2a
00452 res4b14_branch2a_relu = mx.symbol.Activation(name='res4b14_branch2a_relu', data=scale4b14_branch2a, act_type='relu')
00453 res4b14_branch2b = mx.symbol.Convolution(name='res4b14_branch2b', data=res4b14_branch2a_relu, num_filter=256,
00454 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00455 bn4b14_branch2b = mx.symbol.BatchNorm(name='bn4b14_branch2b', data=res4b14_branch2b, use_global_stats=True,
00456 fix_gamma=False, eps=self.eps)
00457 scale4b14_branch2b = bn4b14_branch2b
00458 res4b14_branch2b_relu = mx.symbol.Activation(name='res4b14_branch2b_relu', data=scale4b14_branch2b, act_type='relu')
00459 res4b14_branch2c = mx.symbol.Convolution(name='res4b14_branch2c', data=res4b14_branch2b_relu, num_filter=1024,
00460 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00461 bn4b14_branch2c = mx.symbol.BatchNorm(name='bn4b14_branch2c', data=res4b14_branch2c, use_global_stats=True,
00462 fix_gamma=False, eps=self.eps)
00463 scale4b14_branch2c = bn4b14_branch2c
00464 res4b14 = mx.symbol.broadcast_add(name='res4b14', *[res4b13_relu, scale4b14_branch2c])
00465 res4b14_relu = mx.symbol.Activation(name='res4b14_relu', data=res4b14, act_type='relu')
00466 res4b15_branch2a = mx.symbol.Convolution(name='res4b15_branch2a', data=res4b14_relu, num_filter=256, pad=(0, 0),
00467 kernel=(1, 1), stride=(1, 1), no_bias=True)
00468 bn4b15_branch2a = mx.symbol.BatchNorm(name='bn4b15_branch2a', data=res4b15_branch2a, use_global_stats=True,
00469 fix_gamma=False, eps=self.eps)
00470 scale4b15_branch2a = bn4b15_branch2a
00471 res4b15_branch2a_relu = mx.symbol.Activation(name='res4b15_branch2a_relu', data=scale4b15_branch2a, act_type='relu')
00472 res4b15_branch2b = mx.symbol.Convolution(name='res4b15_branch2b', data=res4b15_branch2a_relu, num_filter=256,
00473 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00474 bn4b15_branch2b = mx.symbol.BatchNorm(name='bn4b15_branch2b', data=res4b15_branch2b, use_global_stats=True,
00475 fix_gamma=False, eps=self.eps)
00476 scale4b15_branch2b = bn4b15_branch2b
00477 res4b15_branch2b_relu = mx.symbol.Activation(name='res4b15_branch2b_relu', data=scale4b15_branch2b, act_type='relu')
00478 res4b15_branch2c = mx.symbol.Convolution(name='res4b15_branch2c', data=res4b15_branch2b_relu, num_filter=1024,
00479 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00480 bn4b15_branch2c = mx.symbol.BatchNorm(name='bn4b15_branch2c', data=res4b15_branch2c, use_global_stats=True,
00481 fix_gamma=False, eps=self.eps)
00482 scale4b15_branch2c = bn4b15_branch2c
00483 res4b15 = mx.symbol.broadcast_add(name='res4b15', *[res4b14_relu, scale4b15_branch2c])
00484 res4b15_relu = mx.symbol.Activation(name='res4b15_relu', data=res4b15, act_type='relu')
00485 res4b16_branch2a = mx.symbol.Convolution(name='res4b16_branch2a', data=res4b15_relu, num_filter=256, pad=(0, 0),
00486 kernel=(1, 1), stride=(1, 1), no_bias=True)
00487 bn4b16_branch2a = mx.symbol.BatchNorm(name='bn4b16_branch2a', data=res4b16_branch2a, use_global_stats=True,
00488 fix_gamma=False, eps=self.eps)
00489 scale4b16_branch2a = bn4b16_branch2a
00490 res4b16_branch2a_relu = mx.symbol.Activation(name='res4b16_branch2a_relu', data=scale4b16_branch2a, act_type='relu')
00491 res4b16_branch2b = mx.symbol.Convolution(name='res4b16_branch2b', data=res4b16_branch2a_relu, num_filter=256,
00492 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00493 bn4b16_branch2b = mx.symbol.BatchNorm(name='bn4b16_branch2b', data=res4b16_branch2b, use_global_stats=True,
00494 fix_gamma=False, eps=self.eps)
00495 scale4b16_branch2b = bn4b16_branch2b
00496 res4b16_branch2b_relu = mx.symbol.Activation(name='res4b16_branch2b_relu', data=scale4b16_branch2b, act_type='relu')
00497 res4b16_branch2c = mx.symbol.Convolution(name='res4b16_branch2c', data=res4b16_branch2b_relu, num_filter=1024,
00498 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00499 bn4b16_branch2c = mx.symbol.BatchNorm(name='bn4b16_branch2c', data=res4b16_branch2c, use_global_stats=True,
00500 fix_gamma=False, eps=self.eps)
00501 scale4b16_branch2c = bn4b16_branch2c
00502 res4b16 = mx.symbol.broadcast_add(name='res4b16', *[res4b15_relu, scale4b16_branch2c])
00503 res4b16_relu = mx.symbol.Activation(name='res4b16_relu', data=res4b16, act_type='relu')
00504 res4b17_branch2a = mx.symbol.Convolution(name='res4b17_branch2a', data=res4b16_relu, num_filter=256, pad=(0, 0),
00505 kernel=(1, 1), stride=(1, 1), no_bias=True)
00506 bn4b17_branch2a = mx.symbol.BatchNorm(name='bn4b17_branch2a', data=res4b17_branch2a, use_global_stats=True,
00507 fix_gamma=False, eps=self.eps)
00508 scale4b17_branch2a = bn4b17_branch2a
00509 res4b17_branch2a_relu = mx.symbol.Activation(name='res4b17_branch2a_relu', data=scale4b17_branch2a, act_type='relu')
00510 res4b17_branch2b = mx.symbol.Convolution(name='res4b17_branch2b', data=res4b17_branch2a_relu, num_filter=256,
00511 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00512 bn4b17_branch2b = mx.symbol.BatchNorm(name='bn4b17_branch2b', data=res4b17_branch2b, use_global_stats=True,
00513 fix_gamma=False, eps=self.eps)
00514 scale4b17_branch2b = bn4b17_branch2b
00515 res4b17_branch2b_relu = mx.symbol.Activation(name='res4b17_branch2b_relu', data=scale4b17_branch2b, act_type='relu')
00516 res4b17_branch2c = mx.symbol.Convolution(name='res4b17_branch2c', data=res4b17_branch2b_relu, num_filter=1024,
00517 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00518 bn4b17_branch2c = mx.symbol.BatchNorm(name='bn4b17_branch2c', data=res4b17_branch2c, use_global_stats=True,
00519 fix_gamma=False, eps=self.eps)
00520 scale4b17_branch2c = bn4b17_branch2c
00521 res4b17 = mx.symbol.broadcast_add(name='res4b17', *[res4b16_relu, scale4b17_branch2c])
00522 res4b17_relu = mx.symbol.Activation(name='res4b17_relu', data=res4b17, act_type='relu')
00523 res4b18_branch2a = mx.symbol.Convolution(name='res4b18_branch2a', data=res4b17_relu, num_filter=256, pad=(0, 0),
00524 kernel=(1, 1), stride=(1, 1), no_bias=True)
00525 bn4b18_branch2a = mx.symbol.BatchNorm(name='bn4b18_branch2a', data=res4b18_branch2a, use_global_stats=True,
00526 fix_gamma=False, eps=self.eps)
00527 scale4b18_branch2a = bn4b18_branch2a
00528 res4b18_branch2a_relu = mx.symbol.Activation(name='res4b18_branch2a_relu', data=scale4b18_branch2a, act_type='relu')
00529 res4b18_branch2b = mx.symbol.Convolution(name='res4b18_branch2b', data=res4b18_branch2a_relu, num_filter=256,
00530 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00531 bn4b18_branch2b = mx.symbol.BatchNorm(name='bn4b18_branch2b', data=res4b18_branch2b, use_global_stats=True,
00532 fix_gamma=False, eps=self.eps)
00533 scale4b18_branch2b = bn4b18_branch2b
00534 res4b18_branch2b_relu = mx.symbol.Activation(name='res4b18_branch2b_relu', data=scale4b18_branch2b, act_type='relu')
00535 res4b18_branch2c = mx.symbol.Convolution(name='res4b18_branch2c', data=res4b18_branch2b_relu, num_filter=1024,
00536 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00537 bn4b18_branch2c = mx.symbol.BatchNorm(name='bn4b18_branch2c', data=res4b18_branch2c, use_global_stats=True,
00538 fix_gamma=False, eps=self.eps)
00539 scale4b18_branch2c = bn4b18_branch2c
00540 res4b18 = mx.symbol.broadcast_add(name='res4b18', *[res4b17_relu, scale4b18_branch2c])
00541 res4b18_relu = mx.symbol.Activation(name='res4b18_relu', data=res4b18, act_type='relu')
00542 res4b19_branch2a = mx.symbol.Convolution(name='res4b19_branch2a', data=res4b18_relu, num_filter=256, pad=(0, 0),
00543 kernel=(1, 1), stride=(1, 1), no_bias=True)
00544 bn4b19_branch2a = mx.symbol.BatchNorm(name='bn4b19_branch2a', data=res4b19_branch2a, use_global_stats=True,
00545 fix_gamma=False, eps=self.eps)
00546 scale4b19_branch2a = bn4b19_branch2a
00547 res4b19_branch2a_relu = mx.symbol.Activation(name='res4b19_branch2a_relu', data=scale4b19_branch2a, act_type='relu')
00548 res4b19_branch2b = mx.symbol.Convolution(name='res4b19_branch2b', data=res4b19_branch2a_relu, num_filter=256,
00549 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00550 bn4b19_branch2b = mx.symbol.BatchNorm(name='bn4b19_branch2b', data=res4b19_branch2b, use_global_stats=True,
00551 fix_gamma=False, eps=self.eps)
00552 scale4b19_branch2b = bn4b19_branch2b
00553 res4b19_branch2b_relu = mx.symbol.Activation(name='res4b19_branch2b_relu', data=scale4b19_branch2b, act_type='relu')
00554 res4b19_branch2c = mx.symbol.Convolution(name='res4b19_branch2c', data=res4b19_branch2b_relu, num_filter=1024,
00555 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00556 bn4b19_branch2c = mx.symbol.BatchNorm(name='bn4b19_branch2c', data=res4b19_branch2c, use_global_stats=True,
00557 fix_gamma=False, eps=self.eps)
00558 scale4b19_branch2c = bn4b19_branch2c
00559 res4b19 = mx.symbol.broadcast_add(name='res4b19', *[res4b18_relu, scale4b19_branch2c])
00560 res4b19_relu = mx.symbol.Activation(name='res4b19_relu', data=res4b19, act_type='relu')
00561 res4b20_branch2a = mx.symbol.Convolution(name='res4b20_branch2a', data=res4b19_relu, num_filter=256, pad=(0, 0),
00562 kernel=(1, 1), stride=(1, 1), no_bias=True)
00563 bn4b20_branch2a = mx.symbol.BatchNorm(name='bn4b20_branch2a', data=res4b20_branch2a, use_global_stats=True,
00564 fix_gamma=False, eps=self.eps)
00565 scale4b20_branch2a = bn4b20_branch2a
00566 res4b20_branch2a_relu = mx.symbol.Activation(name='res4b20_branch2a_relu', data=scale4b20_branch2a, act_type='relu')
00567 res4b20_branch2b = mx.symbol.Convolution(name='res4b20_branch2b', data=res4b20_branch2a_relu, num_filter=256,
00568 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00569 bn4b20_branch2b = mx.symbol.BatchNorm(name='bn4b20_branch2b', data=res4b20_branch2b, use_global_stats=True,
00570 fix_gamma=False, eps=self.eps)
00571 scale4b20_branch2b = bn4b20_branch2b
00572 res4b20_branch2b_relu = mx.symbol.Activation(name='res4b20_branch2b_relu', data=scale4b20_branch2b, act_type='relu')
00573 res4b20_branch2c = mx.symbol.Convolution(name='res4b20_branch2c', data=res4b20_branch2b_relu, num_filter=1024,
00574 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00575 bn4b20_branch2c = mx.symbol.BatchNorm(name='bn4b20_branch2c', data=res4b20_branch2c, use_global_stats=True,
00576 fix_gamma=False, eps=self.eps)
00577 scale4b20_branch2c = bn4b20_branch2c
00578 res4b20 = mx.symbol.broadcast_add(name='res4b20', *[res4b19_relu, scale4b20_branch2c])
00579 res4b20_relu = mx.symbol.Activation(name='res4b20_relu', data=res4b20, act_type='relu')
00580 res4b21_branch2a = mx.symbol.Convolution(name='res4b21_branch2a', data=res4b20_relu, num_filter=256, pad=(0, 0),
00581 kernel=(1, 1), stride=(1, 1), no_bias=True)
00582 bn4b21_branch2a = mx.symbol.BatchNorm(name='bn4b21_branch2a', data=res4b21_branch2a, use_global_stats=True,
00583 fix_gamma=False, eps=self.eps)
00584 scale4b21_branch2a = bn4b21_branch2a
00585 res4b21_branch2a_relu = mx.symbol.Activation(name='res4b21_branch2a_relu', data=scale4b21_branch2a, act_type='relu')
00586 res4b21_branch2b = mx.symbol.Convolution(name='res4b21_branch2b', data=res4b21_branch2a_relu, num_filter=256,
00587 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00588 bn4b21_branch2b = mx.symbol.BatchNorm(name='bn4b21_branch2b', data=res4b21_branch2b, use_global_stats=True,
00589 fix_gamma=False, eps=self.eps)
00590 scale4b21_branch2b = bn4b21_branch2b
00591 res4b21_branch2b_relu = mx.symbol.Activation(name='res4b21_branch2b_relu', data=scale4b21_branch2b, act_type='relu')
00592 res4b21_branch2c = mx.symbol.Convolution(name='res4b21_branch2c', data=res4b21_branch2b_relu, num_filter=1024,
00593 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00594 bn4b21_branch2c = mx.symbol.BatchNorm(name='bn4b21_branch2c', data=res4b21_branch2c, use_global_stats=True,
00595 fix_gamma=False, eps=self.eps)
00596 scale4b21_branch2c = bn4b21_branch2c
00597 res4b21 = mx.symbol.broadcast_add(name='res4b21', *[res4b20_relu, scale4b21_branch2c])
00598 res4b21_relu = mx.symbol.Activation(name='res4b21_relu', data=res4b21, act_type='relu')
00599 res4b22_branch2a = mx.symbol.Convolution(name='res4b22_branch2a', data=res4b21_relu, num_filter=256, pad=(0, 0),
00600 kernel=(1, 1), stride=(1, 1), no_bias=True)
00601 bn4b22_branch2a = mx.symbol.BatchNorm(name='bn4b22_branch2a', data=res4b22_branch2a, use_global_stats=True,
00602 fix_gamma=False, eps=self.eps)
00603 scale4b22_branch2a = bn4b22_branch2a
00604 res4b22_branch2a_relu = mx.symbol.Activation(name='res4b22_branch2a_relu', data=scale4b22_branch2a, act_type='relu')
00605 res4b22_branch2b = mx.symbol.Convolution(name='res4b22_branch2b', data=res4b22_branch2a_relu, num_filter=256,
00606 pad=(1, 1), kernel=(3, 3), stride=(1, 1), no_bias=True)
00607 bn4b22_branch2b = mx.symbol.BatchNorm(name='bn4b22_branch2b', data=res4b22_branch2b, use_global_stats=True,
00608 fix_gamma=False, eps=self.eps)
00609 scale4b22_branch2b = bn4b22_branch2b
00610 res4b22_branch2b_relu = mx.symbol.Activation(name='res4b22_branch2b_relu', data=scale4b22_branch2b, act_type='relu')
00611 res4b22_branch2c = mx.symbol.Convolution(name='res4b22_branch2c', data=res4b22_branch2b_relu, num_filter=1024,
00612 pad=(0, 0), kernel=(1, 1), stride=(1, 1), no_bias=True)
00613 bn4b22_branch2c = mx.symbol.BatchNorm(name='bn4b22_branch2c', data=res4b22_branch2c, use_global_stats=True,
00614 fix_gamma=False, eps=self.eps)
00615 scale4b22_branch2c = bn4b22_branch2c
00616 res4b22 = mx.symbol.broadcast_add(name='res4b22', *[res4b21_relu, scale4b22_branch2c])
00617 res4b22_relu = mx.symbol.Activation(name='res4b22_relu', data=res4b22, act_type='relu')
00618 return res4b22_relu
00619
00620 def get_resnet_v1_conv5(self, conv_feat):
00621 res5a_branch1 = mx.symbol.Convolution(name='res5a_branch1', data=conv_feat, num_filter=2048, pad=(0, 0),
00622 kernel=(1, 1), stride=(1, 1), no_bias=True)
00623 bn5a_branch1 = mx.symbol.BatchNorm(name='bn5a_branch1', data=res5a_branch1, use_global_stats=True, fix_gamma=False, eps=self.eps)
00624 scale5a_branch1 = bn5a_branch1
00625 res5a_branch2a = mx.symbol.Convolution(name='res5a_branch2a', data=conv_feat, num_filter=512, pad=(0, 0),
00626 kernel=(1, 1), stride=(1, 1), no_bias=True)
00627 bn5a_branch2a = mx.symbol.BatchNorm(name='bn5a_branch2a', data=res5a_branch2a, use_global_stats=True,
00628 fix_gamma=False, eps=self.eps)
00629 scale5a_branch2a = bn5a_branch2a
00630 res5a_branch2a_relu = mx.symbol.Activation(name='res5a_branch2a_relu', data=scale5a_branch2a, act_type='relu')
00631 res5a_branch2b_offset = mx.symbol.Convolution(name='res5a_branch2b_offset', data = res5a_branch2a_relu,
00632 num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1), cudnn_off=True)
00633 res5a_branch2b = mx.contrib.symbol.DeformableConvolution(name='res5a_branch2b', data=res5a_branch2a_relu, offset=res5a_branch2b_offset,
00634 num_filter=512, pad=(2, 2), kernel=(3, 3), num_deformable_group=1,
00635 stride=(1, 1), dilate=(2, 2), no_bias=True)
00636 bn5a_branch2b = mx.symbol.BatchNorm(name='bn5a_branch2b', data=res5a_branch2b, use_global_stats=True,
00637 fix_gamma=False, eps=self.eps)
00638 scale5a_branch2b = bn5a_branch2b
00639 res5a_branch2b_relu = mx.symbol.Activation(name='res5a_branch2b_relu', data=scale5a_branch2b, act_type='relu')
00640 res5a_branch2c = mx.symbol.Convolution(name='res5a_branch2c', data=res5a_branch2b_relu, num_filter=2048, pad=(0, 0),
00641 kernel=(1, 1), stride=(1, 1), no_bias=True)
00642 bn5a_branch2c = mx.symbol.BatchNorm(name='bn5a_branch2c', data=res5a_branch2c, use_global_stats=True,
00643 fix_gamma=False, eps=self.eps)
00644 scale5a_branch2c = bn5a_branch2c
00645 res5a = mx.symbol.broadcast_add(name='res5a', *[scale5a_branch1, scale5a_branch2c])
00646 res5a_relu = mx.symbol.Activation(name='res5a_relu', data=res5a, act_type='relu')
00647 res5b_branch2a = mx.symbol.Convolution(name='res5b_branch2a', data=res5a_relu, num_filter=512, pad=(0, 0),
00648 kernel=(1, 1), stride=(1, 1), no_bias=True)
00649 bn5b_branch2a = mx.symbol.BatchNorm(name='bn5b_branch2a', data=res5b_branch2a, use_global_stats=True,
00650 fix_gamma=False, eps=self.eps)
00651 scale5b_branch2a = bn5b_branch2a
00652 res5b_branch2a_relu = mx.symbol.Activation(name='res5b_branch2a_relu', data=scale5b_branch2a, act_type='relu')
00653 res5b_branch2b_offset = mx.symbol.Convolution(name='res5b_branch2b_offset', data = res5b_branch2a_relu,
00654 num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1), cudnn_off=True)
00655 res5b_branch2b = mx.contrib.symbol.DeformableConvolution(name='res5b_branch2b', data=res5b_branch2a_relu, offset=res5b_branch2b_offset,
00656 num_filter=512, pad=(2, 2), kernel=(3, 3), num_deformable_group=1,
00657 stride=(1, 1), dilate=(2, 2), no_bias=True)
00658 bn5b_branch2b = mx.symbol.BatchNorm(name='bn5b_branch2b', data=res5b_branch2b, use_global_stats=True,
00659 fix_gamma=False, eps=self.eps)
00660 scale5b_branch2b = bn5b_branch2b
00661 res5b_branch2b_relu = mx.symbol.Activation(name='res5b_branch2b_relu', data=scale5b_branch2b, act_type='relu')
00662 res5b_branch2c = mx.symbol.Convolution(name='res5b_branch2c', data=res5b_branch2b_relu, num_filter=2048, pad=(0, 0),
00663 kernel=(1, 1), stride=(1, 1), no_bias=True)
00664 bn5b_branch2c = mx.symbol.BatchNorm(name='bn5b_branch2c', data=res5b_branch2c, use_global_stats=True,
00665 fix_gamma=False, eps=self.eps)
00666 scale5b_branch2c = bn5b_branch2c
00667 res5b = mx.symbol.broadcast_add(name='res5b', *[res5a_relu, scale5b_branch2c])
00668 res5b_relu = mx.symbol.Activation(name='res5b_relu', data=res5b, act_type='relu')
00669 res5c_branch2a = mx.symbol.Convolution(name='res5c_branch2a', data=res5b_relu, num_filter=512, pad=(0, 0),
00670 kernel=(1, 1), stride=(1, 1), no_bias=True)
00671 bn5c_branch2a = mx.symbol.BatchNorm(name='bn5c_branch2a', data=res5c_branch2a, use_global_stats=True,
00672 fix_gamma=False, eps=self.eps)
00673 scale5c_branch2a = bn5c_branch2a
00674 res5c_branch2a_relu = mx.symbol.Activation(name='res5c_branch2a_relu', data=scale5c_branch2a, act_type='relu')
00675 res5c_branch2b_offset = mx.symbol.Convolution(name='res5c_branch2b_offset', data = res5c_branch2a_relu,
00676 num_filter=18, pad=(1, 1), kernel=(3, 3), stride=(1, 1), cudnn_off=True)
00677 res5c_branch2b = mx.contrib.symbol.DeformableConvolution(name='res5c_branch2b', data=res5c_branch2a_relu, offset=res5c_branch2b_offset,
00678 num_filter=512, pad=(2, 2), kernel=(3, 3), num_deformable_group=1,
00679 stride=(1, 1), dilate=(2, 2), no_bias=True)
00680 bn5c_branch2b = mx.symbol.BatchNorm(name='bn5c_branch2b', data=res5c_branch2b, use_global_stats=True,
00681 fix_gamma=False, eps=self.eps)
00682 scale5c_branch2b = bn5c_branch2b
00683 res5c_branch2b_relu = mx.symbol.Activation(name='res5c_branch2b_relu', data=scale5c_branch2b, act_type='relu')
00684 res5c_branch2c = mx.symbol.Convolution(name='res5c_branch2c', data=res5c_branch2b_relu, num_filter=2048, pad=(0, 0),
00685 kernel=(1, 1), stride=(1, 1), no_bias=True)
00686 bn5c_branch2c = mx.symbol.BatchNorm(name='bn5c_branch2c', data=res5c_branch2c, use_global_stats=True,
00687 fix_gamma=False, eps=self.eps)
00688 scale5c_branch2c = bn5c_branch2c
00689 res5c = mx.symbol.broadcast_add(name='res5c', *[res5b_relu, scale5c_branch2c])
00690 res5c_relu = mx.symbol.Activation(name='res5c_relu', data=res5c, act_type='relu')
00691 return res5c_relu, res5a_branch2b_offset, res5b_branch2b_offset, res5c_branch2b_offset
00692
00693 def get_rpn(self, conv_feat, num_anchors):
00694 rpn_conv = mx.sym.Convolution(
00695 data=conv_feat, kernel=(3, 3), pad=(1, 1), num_filter=512, name="rpn_conv_3x3")
00696 rpn_relu = mx.sym.Activation(data=rpn_conv, act_type="relu", name="rpn_relu")
00697 rpn_cls_score = mx.sym.Convolution(
00698 data=rpn_relu, kernel=(1, 1), pad=(0, 0), num_filter=2 * num_anchors, name="rpn_cls_score")
00699 rpn_bbox_pred = mx.sym.Convolution(
00700 data=rpn_relu, kernel=(1, 1), pad=(0, 0), num_filter=4 * num_anchors, name="rpn_bbox_pred")
00701 return rpn_cls_score, rpn_bbox_pred
00702
00703 def get_symbol(self, cfg, is_train=True):
00704
00705
00706 num_classes = cfg.dataset.NUM_CLASSES
00707 num_reg_classes = (2 if cfg.CLASS_AGNOSTIC else num_classes)
00708 num_anchors = cfg.network.NUM_ANCHORS
00709
00710
00711 if is_train:
00712 data = mx.sym.Variable(name="data")
00713 im_info = mx.sym.Variable(name="im_info")
00714 gt_boxes = mx.sym.Variable(name="gt_boxes")
00715 rpn_label = mx.sym.Variable(name='label')
00716 rpn_bbox_target = mx.sym.Variable(name='bbox_target')
00717 rpn_bbox_weight = mx.sym.Variable(name='bbox_weight')
00718 else:
00719 data = mx.sym.Variable(name="data")
00720 im_info = mx.sym.Variable(name="im_info")
00721
00722
00723 conv_feat = self.get_resnet_v1_conv4(data)
00724
00725 relu1, res5a_branch2b_offset, res5b_branch2b_offset, res5c_branch2b_offset = self.get_resnet_v1_conv5(conv_feat)
00726
00727 rpn_cls_score, rpn_bbox_pred = self.get_rpn(conv_feat, num_anchors)
00728
00729 if is_train:
00730
00731 rpn_cls_score_reshape = mx.sym.Reshape(
00732 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00733
00734
00735 rpn_cls_prob = mx.sym.SoftmaxOutput(data=rpn_cls_score_reshape, label=rpn_label, multi_output=True,
00736 normalization='valid', use_ignore=True, ignore_label=-1, name="rpn_cls_prob")
00737
00738 rpn_bbox_loss_ = rpn_bbox_weight * mx.sym.smooth_l1(name='rpn_bbox_loss_', scalar=3.0, data=(rpn_bbox_pred - rpn_bbox_target))
00739 rpn_bbox_loss = mx.sym.MakeLoss(name='rpn_bbox_loss', data=rpn_bbox_loss_, grad_scale=1.0 / cfg.TRAIN.RPN_BATCH_SIZE)
00740
00741
00742 rpn_cls_act = mx.sym.SoftmaxActivation(
00743 data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_act")
00744 rpn_cls_act_reshape = mx.sym.Reshape(
00745 data=rpn_cls_act, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_act_reshape')
00746 if cfg.TRAIN.CXX_PROPOSAL:
00747 rois = mx.contrib.sym.Proposal(
00748 cls_prob=rpn_cls_act_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00749 feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00750 rpn_pre_nms_top_n=cfg.TRAIN.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TRAIN.RPN_POST_NMS_TOP_N,
00751 threshold=cfg.TRAIN.RPN_NMS_THRESH, rpn_min_size=cfg.TRAIN.RPN_MIN_SIZE)
00752 else:
00753 rois = mx.sym.Custom(
00754 cls_prob=rpn_cls_act_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00755 op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE,
00756 scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00757 rpn_pre_nms_top_n=cfg.TRAIN.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TRAIN.RPN_POST_NMS_TOP_N,
00758 threshold=cfg.TRAIN.RPN_NMS_THRESH, rpn_min_size=cfg.TRAIN.RPN_MIN_SIZE)
00759
00760 gt_boxes_reshape = mx.sym.Reshape(data=gt_boxes, shape=(-1, 5), name='gt_boxes_reshape')
00761 rois, label, bbox_target, bbox_weight = mx.sym.Custom(rois=rois, gt_boxes=gt_boxes_reshape,
00762 op_type='proposal_target',
00763 num_classes=num_reg_classes,
00764 batch_images=cfg.TRAIN.BATCH_IMAGES,
00765 batch_rois=cfg.TRAIN.BATCH_ROIS,
00766 cfg=cPickle.dumps(cfg),
00767 fg_fraction=cfg.TRAIN.FG_FRACTION)
00768 else:
00769
00770 rpn_cls_score_reshape = mx.sym.Reshape(
00771 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00772 rpn_cls_prob = mx.sym.SoftmaxActivation(
00773 data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_prob")
00774 rpn_cls_prob_reshape = mx.sym.Reshape(
00775 data=rpn_cls_prob, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_prob_reshape')
00776 if cfg.TEST.CXX_PROPOSAL:
00777 rois = mx.contrib.sym.Proposal(
00778 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00779 feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES),
00780 ratios=tuple(cfg.network.ANCHOR_RATIOS),
00781 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00782 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00783 else:
00784 rois = mx.sym.Custom(
00785 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00786 op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE,
00787 scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00788 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00789 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00790
00791
00792
00793
00794 conv_new_1 = mx.sym.Convolution(data=relu1, kernel=(1, 1), num_filter=1024, name="conv_new_1", lr_mult=3.0)
00795 relu_new_1 = mx.sym.Activation(data=conv_new_1, act_type='relu', name='relu1')
00796
00797
00798 rfcn_cls = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=7*7*num_classes, name="rfcn_cls")
00799 rfcn_bbox = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=7*7*4*num_reg_classes, name="rfcn_bbox")
00800 psroipooled_cls_rois = mx.contrib.sym.PSROIPooling(name='psroipooled_cls_rois', data=rfcn_cls, rois=rois, group_size=7, pooled_size=7,
00801 output_dim=num_classes, spatial_scale=0.0625)
00802 psroipooled_loc_rois = mx.contrib.sym.PSROIPooling(name='psroipooled_loc_rois', data=rfcn_bbox, rois=rois, group_size=7, pooled_size=7,
00803 output_dim=8, spatial_scale=0.0625)
00804 cls_score = mx.sym.Pooling(name='ave_cls_scors_rois', data=psroipooled_cls_rois, pool_type='avg', global_pool=True, kernel=(7, 7))
00805 bbox_pred = mx.sym.Pooling(name='ave_bbox_pred_rois', data=psroipooled_loc_rois, pool_type='avg', global_pool=True, kernel=(7, 7))
00806 cls_score = mx.sym.Reshape(name='cls_score_reshape', data=cls_score, shape=(-1, num_classes))
00807 bbox_pred = mx.sym.Reshape(name='bbox_pred_reshape', data=bbox_pred, shape=(-1, 4 * num_reg_classes))
00808
00809 if is_train:
00810 if cfg.TRAIN.ENABLE_OHEM:
00811 labels_ohem, bbox_weights_ohem = mx.sym.Custom(op_type='BoxAnnotatorOHEM', num_classes=num_classes,
00812 num_reg_classes=num_reg_classes, roi_per_img=cfg.TRAIN.BATCH_ROIS_OHEM,
00813 cls_score=cls_score, bbox_pred=bbox_pred, labels=label,
00814 bbox_targets=bbox_target, bbox_weights=bbox_weight)
00815 cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=labels_ohem, normalization='valid', use_ignore=True, ignore_label=-1)
00816 bbox_loss_ = bbox_weights_ohem * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00817 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS_OHEM)
00818 rcnn_label = labels_ohem
00819 else:
00820 cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=label, normalization='valid')
00821 bbox_loss_ = bbox_weight * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00822 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS)
00823 rcnn_label = label
00824
00825
00826 rcnn_label = mx.sym.Reshape(data=rcnn_label, shape=(cfg.TRAIN.BATCH_IMAGES, -1), name='label_reshape')
00827 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TRAIN.BATCH_IMAGES, -1, num_classes), name='cls_prob_reshape')
00828 bbox_loss = mx.sym.Reshape(data=bbox_loss, shape=(cfg.TRAIN.BATCH_IMAGES, -1, 4 * num_reg_classes), name='bbox_loss_reshape')
00829 group = mx.sym.Group([rpn_cls_prob, rpn_bbox_loss, cls_prob, bbox_loss, mx.sym.BlockGrad(rcnn_label)])
00830 else:
00831 cls_prob = mx.sym.SoftmaxActivation(name='cls_prob', data=cls_score)
00832 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TEST.BATCH_IMAGES, -1, num_classes),
00833 name='cls_prob_reshape')
00834 bbox_pred = mx.sym.Reshape(data=bbox_pred, shape=(cfg.TEST.BATCH_IMAGES, -1, 4 * num_reg_classes),
00835 name='bbox_pred_reshape')
00836 group = mx.sym.Group([res5a_branch2b_offset, res5b_branch2b_offset, res5c_branch2b_offset, rois, cls_prob, bbox_pred])
00837
00838 self.sym = group
00839 return group
00840
00841 def get_symbol_rpn(self, cfg, is_train=True):
00842
00843 num_anchors = cfg.network.NUM_ANCHORS
00844
00845
00846 if is_train:
00847 data = mx.sym.Variable(name="data")
00848 rpn_label = mx.sym.Variable(name='label')
00849 rpn_bbox_target = mx.sym.Variable(name='bbox_target')
00850 rpn_bbox_weight = mx.sym.Variable(name='bbox_weight')
00851 else:
00852 data = mx.sym.Variable(name="data")
00853 im_info = mx.sym.Variable(name="im_info")
00854
00855
00856 conv_feat = self.get_resnet_v1_conv4(data)
00857 rpn_cls_score, rpn_bbox_pred = self.get_rpn(conv_feat, num_anchors)
00858 if is_train:
00859
00860 rpn_cls_score_reshape = mx.sym.Reshape(
00861 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00862
00863
00864 rpn_cls_prob = mx.sym.SoftmaxOutput(data=rpn_cls_score_reshape, label=rpn_label, multi_output=True,
00865 normalization='valid', use_ignore=True, ignore_label=-1, name="rpn_cls_prob",
00866 grad_scale=1.0)
00867
00868 rpn_bbox_loss_ = rpn_bbox_weight * mx.sym.smooth_l1(name='rpn_bbox_loss_', scalar=3.0, data=(rpn_bbox_pred - rpn_bbox_target))
00869 rpn_bbox_loss = mx.sym.MakeLoss(name='rpn_bbox_loss', data=rpn_bbox_loss_, grad_scale=1.0 / cfg.TRAIN.RPN_BATCH_SIZE)
00870 group = mx.symbol.Group([rpn_cls_prob, rpn_bbox_loss])
00871 else:
00872
00873 rpn_cls_score_reshape = mx.sym.Reshape(
00874 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00875 rpn_cls_prob = mx.sym.SoftmaxActivation(
00876 data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_prob")
00877 rpn_cls_prob_reshape = mx.sym.Reshape(
00878 data=rpn_cls_prob, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_prob_reshape')
00879 if cfg.TEST.CXX_PROPOSAL:
00880 rois, score = mx.contrib.sym.Proposal(
00881 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', output_score=True,
00882 feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES),
00883 ratios=tuple(cfg.network.ANCHOR_RATIOS),
00884 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00885 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00886 else:
00887 rois, score = mx.sym.Custom(
00888 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', output_score=True,
00889 op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE,
00890 scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00891 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00892 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00893 group = mx.symbol.Group([rois, score])
00894 self.sym = group
00895 return group
00896
00897 def get_symbol_rfcn(self, cfg, is_train=True):
00898
00899
00900 num_classes = cfg.dataset.NUM_CLASSES
00901 num_reg_classes = (2 if cfg.CLASS_AGNOSTIC else num_classes)
00902
00903
00904 if is_train:
00905 data = mx.symbol.Variable(name="data")
00906 rois = mx.symbol.Variable(name='rois')
00907 label = mx.symbol.Variable(name='label')
00908 bbox_target = mx.symbol.Variable(name='bbox_target')
00909 bbox_weight = mx.symbol.Variable(name='bbox_weight')
00910
00911 rois = mx.symbol.Reshape(data=rois, shape=(-1, 5), name='rois_reshape')
00912 label = mx.symbol.Reshape(data=label, shape=(-1,), name='label_reshape')
00913 bbox_target = mx.symbol.Reshape(data=bbox_target, shape=(-1, 4 * num_reg_classes), name='bbox_target_reshape')
00914 bbox_weight = mx.symbol.Reshape(data=bbox_weight, shape=(-1, 4 * num_reg_classes), name='bbox_weight_reshape')
00915 else:
00916 data = mx.sym.Variable(name="data")
00917 rois = mx.symbol.Variable(name='rois')
00918
00919 rois = mx.symbol.Reshape(data=rois, shape=(-1, 5), name='rois_reshape')
00920
00921
00922 conv_feat = self.get_resnet_v1_conv4(data)
00923 relu1, res5a_branch2b_offset, res5b_branch2b_offset, res5c_branch2b_offset = self.get_resnet_v1_conv5(conv_feat)
00924
00925
00926 conv_new_1 = mx.sym.Convolution(data=relu1, kernel=(1, 1), num_filter=1024, name="conv_new_1", lr_mult=3.0)
00927 relu_new_1 = mx.sym.Activation(data=conv_new_1, act_type='relu', name='relu1')
00928
00929
00930 rfcn_cls = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=7*7*num_classes, name="rfcn_cls")
00931 rfcn_bbox = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=7*7*4*num_reg_classes, name="rfcn_bbox")
00932 psroipooled_cls_rois = mx.contrib.sym.PSROIPooling(name='psroipooled_cls_rois', data=rfcn_cls, rois=rois, group_size=7, pooled_size=7,
00933 output_dim=num_classes, spatial_scale=0.0625)
00934 psroipooled_loc_rois = mx.contrib.sym.PSROIPooling(name='psroipooled_loc_rois', data=rfcn_bbox, rois=rois, group_size=7, pooled_size=7,
00935 output_dim=8, spatial_scale=0.0625)
00936 cls_score = mx.sym.Pooling(name='ave_cls_scors_rois', data=psroipooled_cls_rois, pool_type='avg', global_pool=True, kernel=(7, 7))
00937 bbox_pred = mx.sym.Pooling(name='ave_bbox_pred_rois', data=psroipooled_loc_rois, pool_type='avg', global_pool=True, kernel=(7, 7))
00938 cls_score = mx.sym.Reshape(name='cls_score_reshape', data=cls_score, shape=(-1, num_classes))
00939 bbox_pred = mx.sym.Reshape(name='bbox_pred_reshape', data=bbox_pred, shape=(-1, 4 * num_reg_classes))
00940
00941 if is_train:
00942 if cfg.TRAIN.ENABLE_OHEM:
00943 labels_ohem, bbox_weights_ohem = mx.sym.Custom(op_type='BoxAnnotatorOHEM', num_classes=num_classes,
00944 num_reg_classes=num_reg_classes, roi_per_img=cfg.TRAIN.BATCH_ROIS_OHEM,
00945 cls_score=cls_score, bbox_pred=bbox_pred, labels=label,
00946 bbox_targets=bbox_target, bbox_weights=bbox_weight)
00947 cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=labels_ohem, normalization='valid', use_ignore=True, ignore_label=-1, grad_scale=1.0)
00948 bbox_loss_ = bbox_weights_ohem * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00949 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS_OHEM)
00950 label = labels_ohem
00951 else:
00952 cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=label, normalization='valid', grad_scale=1.0)
00953 bbox_loss_ = bbox_weight * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00954 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS)
00955
00956
00957 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TRAIN.BATCH_IMAGES, -1, num_classes), name='cls_prob_reshape')
00958 bbox_loss = mx.sym.Reshape(data=bbox_loss, shape=(cfg.TRAIN.BATCH_IMAGES, -1, 4 * num_reg_classes), name='bbox_loss_reshape')
00959 group = mx.sym.Group([cls_prob, bbox_loss, mx.sym.BlockGrad(label)]) if cfg.TRAIN.ENABLE_OHEM else mx.sym.Group([cls_prob, bbox_loss])
00960 else:
00961 cls_prob = mx.sym.SoftmaxActivation(name='cls_prob', data=cls_score)
00962 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TEST.BATCH_IMAGES, -1, num_classes),
00963 name='cls_prob_reshape')
00964 bbox_pred = mx.sym.Reshape(data=bbox_pred, shape=(cfg.TEST.BATCH_IMAGES, -1, 4 * num_reg_classes),
00965 name='bbox_pred_reshape')
00966 group = mx.sym.Group([res5a_branch2b_offset, res5b_branch2b_offset, res5c_branch2b_offset, cls_prob, bbox_pred])
00967
00968 self.sym = group
00969 return group
00970
00971 def init_weight_rpn(self, cfg, arg_params, aux_params):
00972 arg_params['rpn_conv_3x3_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rpn_conv_3x3_weight'])
00973 arg_params['rpn_conv_3x3_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rpn_conv_3x3_bias'])
00974 arg_params['rpn_cls_score_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rpn_cls_score_weight'])
00975 arg_params['rpn_cls_score_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rpn_cls_score_bias'])
00976 arg_params['rpn_bbox_pred_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rpn_bbox_pred_weight'])
00977 arg_params['rpn_bbox_pred_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rpn_bbox_pred_bias'])
00978
00979 def init_weight_rfcn(self, cfg, arg_params, aux_params):
00980 arg_params['res5a_branch2b_offset_weight'] = mx.nd.zeros(shape=self.arg_shape_dict['res5a_branch2b_offset_weight'])
00981 arg_params['res5a_branch2b_offset_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['res5a_branch2b_offset_bias'])
00982 arg_params['res5b_branch2b_offset_weight'] = mx.nd.zeros(shape=self.arg_shape_dict['res5b_branch2b_offset_weight'])
00983 arg_params['res5b_branch2b_offset_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['res5b_branch2b_offset_bias'])
00984 arg_params['res5c_branch2b_offset_weight'] = mx.nd.zeros(shape=self.arg_shape_dict['res5c_branch2b_offset_weight'])
00985 arg_params['res5c_branch2b_offset_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['res5c_branch2b_offset_bias'])
00986 arg_params['conv_new_1_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['conv_new_1_weight'])
00987 arg_params['conv_new_1_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['conv_new_1_bias'])
00988 arg_params['rfcn_cls_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rfcn_cls_weight'])
00989 arg_params['rfcn_cls_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_cls_bias'])
00990 arg_params['rfcn_bbox_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rfcn_bbox_weight'])
00991 arg_params['rfcn_bbox_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_bbox_bias'])
00992
00993 def init_weight(self, cfg, arg_params, aux_params):
00994 self.init_weight_rpn(cfg, arg_params, aux_params)
00995 self.init_weight_rfcn(cfg, arg_params, aux_params)