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_psroi_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 = mx.symbol.Convolution(name='res5a_branch2b', data=res5a_branch2a_relu, num_filter=512, pad=(2, 2),
00632 kernel=(3, 3), stride=(1, 1), dilate=(2, 2), no_bias=True, cudnn_off=True)
00633 bn5a_branch2b = mx.symbol.BatchNorm(name='bn5a_branch2b', data=res5a_branch2b, use_global_stats=True,
00634 fix_gamma=False, eps=self.eps)
00635 scale5a_branch2b = bn5a_branch2b
00636 res5a_branch2b_relu = mx.symbol.Activation(name='res5a_branch2b_relu', data=scale5a_branch2b, act_type='relu')
00637 res5a_branch2c = mx.symbol.Convolution(name='res5a_branch2c', data=res5a_branch2b_relu, num_filter=2048, pad=(0, 0),
00638 kernel=(1, 1), stride=(1, 1), no_bias=True)
00639 bn5a_branch2c = mx.symbol.BatchNorm(name='bn5a_branch2c', data=res5a_branch2c, use_global_stats=True,
00640 fix_gamma=False, eps=self.eps)
00641 scale5a_branch2c = bn5a_branch2c
00642 res5a = mx.symbol.broadcast_add(name='res5a', *[scale5a_branch1, scale5a_branch2c])
00643 res5a_relu = mx.symbol.Activation(name='res5a_relu', data=res5a, act_type='relu')
00644 res5b_branch2a = mx.symbol.Convolution(name='res5b_branch2a', data=res5a_relu, num_filter=512, pad=(0, 0),
00645 kernel=(1, 1), stride=(1, 1), no_bias=True)
00646 bn5b_branch2a = mx.symbol.BatchNorm(name='bn5b_branch2a', data=res5b_branch2a, use_global_stats=True,
00647 fix_gamma=False, eps=self.eps)
00648 scale5b_branch2a = bn5b_branch2a
00649 res5b_branch2a_relu = mx.symbol.Activation(name='res5b_branch2a_relu', data=scale5b_branch2a, act_type='relu')
00650 res5b_branch2b = mx.symbol.Convolution(name='res5b_branch2b', data=res5b_branch2a_relu, num_filter=512, pad=(2, 2),
00651 kernel=(3, 3), stride=(1, 1), dilate=(2, 2), no_bias=True, cudnn_off=True)
00652 bn5b_branch2b = mx.symbol.BatchNorm(name='bn5b_branch2b', data=res5b_branch2b, use_global_stats=True,
00653 fix_gamma=False, eps=self.eps)
00654 scale5b_branch2b = bn5b_branch2b
00655 res5b_branch2b_relu = mx.symbol.Activation(name='res5b_branch2b_relu', data=scale5b_branch2b, act_type='relu')
00656 res5b_branch2c = mx.symbol.Convolution(name='res5b_branch2c', data=res5b_branch2b_relu, num_filter=2048, pad=(0, 0),
00657 kernel=(1, 1), stride=(1, 1), no_bias=True)
00658 bn5b_branch2c = mx.symbol.BatchNorm(name='bn5b_branch2c', data=res5b_branch2c, use_global_stats=True,
00659 fix_gamma=False, eps=self.eps)
00660 scale5b_branch2c = bn5b_branch2c
00661 res5b = mx.symbol.broadcast_add(name='res5b', *[res5a_relu, scale5b_branch2c])
00662 res5b_relu = mx.symbol.Activation(name='res5b_relu', data=res5b, act_type='relu')
00663 res5c_branch2a = mx.symbol.Convolution(name='res5c_branch2a', data=res5b_relu, num_filter=512, pad=(0, 0),
00664 kernel=(1, 1), stride=(1, 1), no_bias=True)
00665 bn5c_branch2a = mx.symbol.BatchNorm(name='bn5c_branch2a', data=res5c_branch2a, use_global_stats=True,
00666 fix_gamma=False, eps=self.eps)
00667 scale5c_branch2a = bn5c_branch2a
00668 res5c_branch2a_relu = mx.symbol.Activation(name='res5c_branch2a_relu', data=scale5c_branch2a, act_type='relu')
00669 res5c_branch2b = mx.symbol.Convolution(name='res5c_branch2b', data=res5c_branch2a_relu, num_filter=512, pad=(2, 2),
00670 kernel=(3, 3), stride=(1, 1), dilate=(2, 2), no_bias=True, cudnn_off=True)
00671 bn5c_branch2b = mx.symbol.BatchNorm(name='bn5c_branch2b', data=res5c_branch2b, use_global_stats=True,
00672 fix_gamma=False, eps=self.eps)
00673 scale5c_branch2b = bn5c_branch2b
00674 res5c_branch2b_relu = mx.symbol.Activation(name='res5c_branch2b_relu', data=scale5c_branch2b, act_type='relu')
00675 res5c_branch2c = mx.symbol.Convolution(name='res5c_branch2c', data=res5c_branch2b_relu, num_filter=2048, pad=(0, 0),
00676 kernel=(1, 1), stride=(1, 1), no_bias=True)
00677 bn5c_branch2c = mx.symbol.BatchNorm(name='bn5c_branch2c', data=res5c_branch2c, use_global_stats=True,
00678 fix_gamma=False, eps=self.eps)
00679 scale5c_branch2c = bn5c_branch2c
00680 res5c = mx.symbol.broadcast_add(name='res5c', *[res5b_relu, scale5c_branch2c])
00681 res5c_relu = mx.symbol.Activation(name='res5c_relu', data=res5c, act_type='relu')
00682 return res5c_relu
00683
00684 def get_rpn(self, conv_feat, num_anchors):
00685 rpn_conv = mx.sym.Convolution(
00686 data=conv_feat, kernel=(3, 3), pad=(1, 1), num_filter=512, name="rpn_conv_3x3")
00687 rpn_relu = mx.sym.Activation(data=rpn_conv, act_type="relu", name="rpn_relu")
00688 rpn_cls_score = mx.sym.Convolution(
00689 data=rpn_relu, kernel=(1, 1), pad=(0, 0), num_filter=2 * num_anchors, name="rpn_cls_score")
00690 rpn_bbox_pred = mx.sym.Convolution(
00691 data=rpn_relu, kernel=(1, 1), pad=(0, 0), num_filter=4 * num_anchors, name="rpn_bbox_pred")
00692 return rpn_cls_score, rpn_bbox_pred
00693
00694 def get_symbol(self, cfg, is_train=True):
00695
00696
00697 num_classes = cfg.dataset.NUM_CLASSES
00698 num_reg_classes = (2 if cfg.CLASS_AGNOSTIC else num_classes)
00699 num_anchors = cfg.network.NUM_ANCHORS
00700
00701
00702 if is_train:
00703 data = mx.sym.Variable(name="data")
00704 im_info = mx.sym.Variable(name="im_info")
00705 gt_boxes = mx.sym.Variable(name="gt_boxes")
00706 rpn_label = mx.sym.Variable(name='label')
00707 rpn_bbox_target = mx.sym.Variable(name='bbox_target')
00708 rpn_bbox_weight = mx.sym.Variable(name='bbox_weight')
00709 else:
00710 data = mx.sym.Variable(name="data")
00711 im_info = mx.sym.Variable(name="im_info")
00712
00713
00714 conv_feat = self.get_resnet_v1_conv4(data)
00715
00716 relu1 = self.get_resnet_v1_conv5(conv_feat)
00717
00718 rpn_cls_score, rpn_bbox_pred = self.get_rpn(conv_feat, num_anchors)
00719
00720 if is_train:
00721
00722 rpn_cls_score_reshape = mx.sym.Reshape(
00723 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00724
00725
00726 rpn_cls_prob = mx.sym.SoftmaxOutput(data=rpn_cls_score_reshape, label=rpn_label, multi_output=True,
00727 normalization='valid', use_ignore=True, ignore_label=-1, name="rpn_cls_prob")
00728
00729 rpn_bbox_loss_ = rpn_bbox_weight * mx.sym.smooth_l1(name='rpn_bbox_loss_', scalar=3.0, data=(rpn_bbox_pred - rpn_bbox_target))
00730 rpn_bbox_loss = mx.sym.MakeLoss(name='rpn_bbox_loss', data=rpn_bbox_loss_, grad_scale=1.0 / cfg.TRAIN.RPN_BATCH_SIZE)
00731
00732
00733 rpn_cls_act = mx.sym.SoftmaxActivation(
00734 data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_act")
00735 rpn_cls_act_reshape = mx.sym.Reshape(
00736 data=rpn_cls_act, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_act_reshape')
00737 if cfg.TRAIN.CXX_PROPOSAL:
00738 rois = mx.contrib.sym.Proposal(
00739 cls_prob=rpn_cls_act_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00740 feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00741 rpn_pre_nms_top_n=cfg.TRAIN.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TRAIN.RPN_POST_NMS_TOP_N,
00742 threshold=cfg.TRAIN.RPN_NMS_THRESH, rpn_min_size=cfg.TRAIN.RPN_MIN_SIZE)
00743 else:
00744 rois = mx.sym.Custom(
00745 cls_prob=rpn_cls_act_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00746 op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE,
00747 scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00748 rpn_pre_nms_top_n=cfg.TRAIN.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TRAIN.RPN_POST_NMS_TOP_N,
00749 threshold=cfg.TRAIN.RPN_NMS_THRESH, rpn_min_size=cfg.TRAIN.RPN_MIN_SIZE)
00750
00751 gt_boxes_reshape = mx.sym.Reshape(data=gt_boxes, shape=(-1, 5), name='gt_boxes_reshape')
00752 rois, label, bbox_target, bbox_weight = mx.sym.Custom(rois=rois, gt_boxes=gt_boxes_reshape,
00753 op_type='proposal_target',
00754 num_classes=num_reg_classes,
00755 batch_images=cfg.TRAIN.BATCH_IMAGES,
00756 batch_rois=cfg.TRAIN.BATCH_ROIS,
00757 cfg=cPickle.dumps(cfg),
00758 fg_fraction=cfg.TRAIN.FG_FRACTION)
00759 else:
00760
00761 rpn_cls_score_reshape = mx.sym.Reshape(
00762 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00763 rpn_cls_prob = mx.sym.SoftmaxActivation(
00764 data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_prob")
00765 rpn_cls_prob_reshape = mx.sym.Reshape(
00766 data=rpn_cls_prob, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_prob_reshape')
00767 if cfg.TEST.CXX_PROPOSAL:
00768 rois = mx.contrib.sym.Proposal(
00769 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00770 feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES),
00771 ratios=tuple(cfg.network.ANCHOR_RATIOS),
00772 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00773 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00774 else:
00775 rois = mx.sym.Custom(
00776 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois',
00777 op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE,
00778 scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00779 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00780 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00781
00782
00783
00784
00785 conv_new_1 = mx.sym.Convolution(data=relu1, kernel=(1, 1), num_filter=1024, name="conv_new_1", lr_mult=3.0)
00786 relu_new_1 = mx.sym.Activation(data=conv_new_1, act_type='relu', name='relu1')
00787
00788
00789 rfcn_cls = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=3*3*num_classes, name="rfcn_cls")
00790 rfcn_bbox = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=3*3*4*num_reg_classes, name="rfcn_bbox")
00791
00792 rfcn_cls_offset_t = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=2 * 3 * 3 * num_classes, name="rfcn_cls_offset_t")
00793 rfcn_bbox_offset_t = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=3 * 3 * 2, name="rfcn_bbox_offset_t")
00794
00795 rfcn_cls_offset = mx.contrib.sym.DeformablePSROIPooling(name='rfcn_cls_offset', data=rfcn_cls_offset_t, rois=rois, group_size=3, pooled_size=3,
00796 sample_per_part=4, no_trans=True, part_size=3, output_dim=2 * num_classes, spatial_scale=0.0625)
00797 rfcn_bbox_offset = mx.contrib.sym.DeformablePSROIPooling(name='rfcn_bbox_offset', data=rfcn_bbox_offset_t, rois=rois, group_size=3, pooled_size=3,
00798 sample_per_part=4, no_trans=True, part_size=3, output_dim=2, spatial_scale=0.0625)
00799
00800 psroipooled_cls_rois = mx.contrib.sym.DeformablePSROIPooling(name='psroipooled_cls_rois', data=rfcn_cls, rois=rois, trans=rfcn_cls_offset,
00801 group_size=3, pooled_size=3, sample_per_part=4, no_trans=False, trans_std=0.1,
00802 output_dim=num_classes, spatial_scale=0.0625, part_size=3)
00803 psroipooled_loc_rois = mx.contrib.sym.DeformablePSROIPooling(name='psroipooled_loc_rois', data=rfcn_bbox, rois=rois, trans=rfcn_bbox_offset,
00804 group_size=3, pooled_size=3, sample_per_part=4, no_trans=False, trans_std=0.1,
00805 output_dim=8, spatial_scale=0.0625, part_size=3)
00806 cls_score = mx.sym.Pooling(name='ave_cls_scors_rois', data=psroipooled_cls_rois, pool_type='avg', global_pool=True, kernel=(3, 3))
00807 bbox_pred = mx.sym.Pooling(name='ave_bbox_pred_rois', data=psroipooled_loc_rois, pool_type='avg', global_pool=True, kernel=(3, 3))
00808 cls_score = mx.sym.Reshape(name='cls_score_reshape', data=cls_score, shape=(-1, num_classes))
00809 bbox_pred = mx.sym.Reshape(name='bbox_pred_reshape', data=bbox_pred, shape=(-1, 4 * num_reg_classes))
00810
00811 if is_train:
00812 if cfg.TRAIN.ENABLE_OHEM:
00813 labels_ohem, bbox_weights_ohem = mx.sym.Custom(op_type='BoxAnnotatorOHEM', num_classes=num_classes,
00814 num_reg_classes=num_reg_classes, roi_per_img=cfg.TRAIN.BATCH_ROIS_OHEM,
00815 cls_score=cls_score, bbox_pred=bbox_pred, labels=label,
00816 bbox_targets=bbox_target, bbox_weights=bbox_weight)
00817 cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=labels_ohem, normalization='valid', use_ignore=True, ignore_label=-1)
00818 bbox_loss_ = bbox_weights_ohem * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00819 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS_OHEM)
00820 rcnn_label = labels_ohem
00821 else:
00822 cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=label, normalization='valid')
00823 bbox_loss_ = bbox_weight * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00824 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS)
00825 rcnn_label = label
00826
00827
00828 rcnn_label = mx.sym.Reshape(data=rcnn_label, shape=(cfg.TRAIN.BATCH_IMAGES, -1), name='label_reshape')
00829 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TRAIN.BATCH_IMAGES, -1, num_classes), name='cls_prob_reshape')
00830 bbox_loss = mx.sym.Reshape(data=bbox_loss, shape=(cfg.TRAIN.BATCH_IMAGES, -1, 4 * num_reg_classes), name='bbox_loss_reshape')
00831 group = mx.sym.Group([rpn_cls_prob, rpn_bbox_loss, cls_prob, bbox_loss, mx.sym.BlockGrad(rcnn_label)])
00832 else:
00833 cls_prob = mx.sym.SoftmaxActivation(name='cls_prob', data=cls_score)
00834 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TEST.BATCH_IMAGES, -1, num_classes),
00835 name='cls_prob_reshape')
00836 bbox_pred = mx.sym.Reshape(data=bbox_pred, shape=(cfg.TEST.BATCH_IMAGES, -1, 4 * num_reg_classes),
00837 name='bbox_pred_reshape')
00838 group = mx.sym.Group([rfcn_cls_offset, rois, cls_prob, bbox_pred])
00839
00840 self.sym = group
00841 return group
00842
00843 def get_symbol_rpn(self, cfg, is_train=True):
00844
00845 num_anchors = cfg.network.NUM_ANCHORS
00846
00847
00848 if is_train:
00849 data = mx.sym.Variable(name="data")
00850 rpn_label = mx.sym.Variable(name='label')
00851 rpn_bbox_target = mx.sym.Variable(name='bbox_target')
00852 rpn_bbox_weight = mx.sym.Variable(name='bbox_weight')
00853 else:
00854 data = mx.sym.Variable(name="data")
00855 im_info = mx.sym.Variable(name="im_info")
00856
00857
00858 conv_feat = self.get_resnet_v1_conv4(data)
00859 rpn_cls_score, rpn_bbox_pred = self.get_rpn(conv_feat, num_anchors)
00860 if is_train:
00861
00862 rpn_cls_score_reshape = mx.sym.Reshape(
00863 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00864
00865
00866 rpn_cls_prob = mx.sym.SoftmaxOutput(data=rpn_cls_score_reshape, label=rpn_label, multi_output=True,
00867 normalization='valid', use_ignore=True, ignore_label=-1, name="rpn_cls_prob",
00868 grad_scale=1.0)
00869
00870 rpn_bbox_loss_ = rpn_bbox_weight * mx.sym.smooth_l1(name='rpn_bbox_loss_', scalar=3.0, data=(rpn_bbox_pred - rpn_bbox_target))
00871 rpn_bbox_loss = mx.sym.MakeLoss(name='rpn_bbox_loss', data=rpn_bbox_loss_, grad_scale=1.0 / cfg.TRAIN.RPN_BATCH_SIZE)
00872 group = mx.symbol.Group([rpn_cls_prob, rpn_bbox_loss])
00873 else:
00874
00875 rpn_cls_score_reshape = mx.sym.Reshape(
00876 data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape")
00877 rpn_cls_prob = mx.sym.SoftmaxActivation(
00878 data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_prob")
00879 rpn_cls_prob_reshape = mx.sym.Reshape(
00880 data=rpn_cls_prob, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_prob_reshape')
00881 if cfg.TEST.CXX_PROPOSAL:
00882 rois, score = mx.contrib.sym.Proposal(
00883 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', output_score=True,
00884 feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES),
00885 ratios=tuple(cfg.network.ANCHOR_RATIOS),
00886 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00887 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00888 else:
00889 rois, score = mx.sym.Custom(
00890 cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', output_score=True,
00891 op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE,
00892 scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS),
00893 rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N,
00894 threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE)
00895 group = mx.symbol.Group([rois, score])
00896 self.sym = group
00897 return group
00898
00899 def get_symbol_rfcn(self, cfg, is_train=True):
00900
00901
00902 num_classes = cfg.dataset.NUM_CLASSES
00903 num_reg_classes = (2 if cfg.CLASS_AGNOSTIC else num_classes)
00904
00905
00906 if is_train:
00907 data = mx.symbol.Variable(name="data")
00908 rois = mx.symbol.Variable(name='rois')
00909 label = mx.symbol.Variable(name='label')
00910 bbox_target = mx.symbol.Variable(name='bbox_target')
00911 bbox_weight = mx.symbol.Variable(name='bbox_weight')
00912
00913 rois = mx.symbol.Reshape(data=rois, shape=(-1, 5), name='rois_reshape')
00914 label = mx.symbol.Reshape(data=label, shape=(-1,), name='label_reshape')
00915 bbox_target = mx.symbol.Reshape(data=bbox_target, shape=(-1, 4 * num_reg_classes), name='bbox_target_reshape')
00916 bbox_weight = mx.symbol.Reshape(data=bbox_weight, shape=(-1, 4 * num_reg_classes), name='bbox_weight_reshape')
00917 else:
00918 data = mx.sym.Variable(name="data")
00919 rois = mx.symbol.Variable(name='rois')
00920
00921 rois = mx.symbol.Reshape(data=rois, shape=(-1, 5), name='rois_reshape')
00922
00923
00924 conv_feat = self.get_resnet_v1_conv4(data)
00925 relu1 = self.get_resnet_v1_conv5(conv_feat)
00926
00927
00928 conv_new_1 = mx.sym.Convolution(data=relu1, kernel=(1, 1), num_filter=1024, name="conv_new_1", lr_mult=3.0)
00929 relu_new_1 = mx.sym.Activation(data=conv_new_1, act_type='relu', name='relu1')
00930
00931
00932 rfcn_cls = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=3*3*num_classes, name="rfcn_cls")
00933 rfcn_bbox = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=3*3*4*num_reg_classes, name="rfcn_bbox")
00934
00935 rfcn_cls_offset_t = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=2 * 3 * 3 * num_classes, name="rfcn_cls_offset_t")
00936 rfcn_bbox_offset_t = mx.sym.Convolution(data=relu_new_1, kernel=(1, 1), num_filter=3 * 3 * 2, name="rfcn_bbox_offset_t")
00937
00938 rfcn_cls_offset = mx.contrib.sym.DeformablePSROIPooling(name='rfcn_cls_offset', data=rfcn_cls_offset_t, rois=rois, group_size=3, pooled_size=3,
00939 sample_per_part=4, no_trans=True, part_size=3, output_dim=2 * num_classes, spatial_scale=0.0625)
00940 rfcn_bbox_offset = mx.contrib.sym.DeformablePSROIPooling(name='rfcn_bbox_offset', data=rfcn_bbox_offset_t, rois=rois, group_size=3, pooled_size=3,
00941 sample_per_part=4, no_trans=True, part_size=3, output_dim=2, spatial_scale=0.0625)
00942
00943 psroipooled_cls_rois = mx.contrib.sym.DeformablePSROIPooling(name='psroipooled_cls_rois', data=rfcn_cls, rois=rois, trans=rfcn_cls_offset,
00944 group_size=3, pooled_size=3, sample_per_part=4, no_trans=False, trans_std=0.1,
00945 output_dim=num_classes, spatial_scale=0.0625, part_size=3)
00946 psroipooled_loc_rois = mx.contrib.sym.DeformablePSROIPooling(name='psroipooled_loc_rois', data=rfcn_bbox, rois=rois, trans=rfcn_bbox_offset,
00947 group_size=3, pooled_size=3, sample_per_part=4, no_trans=False, trans_std=0.1,
00948 output_dim=8, spatial_scale=0.0625, part_size=3)
00949 cls_score = mx.sym.Pooling(name='ave_cls_scors_rois', data=psroipooled_cls_rois, pool_type='avg', global_pool=True, kernel=(3, 3))
00950 bbox_pred = mx.sym.Pooling(name='ave_bbox_pred_rois', data=psroipooled_loc_rois, pool_type='avg', global_pool=True, kernel=(3, 3))
00951 cls_score = mx.sym.Reshape(name='cls_score_reshape', data=cls_score, shape=(-1, num_classes))
00952 bbox_pred = mx.sym.Reshape(name='bbox_pred_reshape', data=bbox_pred, shape=(-1, 4 * num_reg_classes))
00953
00954 if is_train:
00955 if cfg.TRAIN.ENABLE_OHEM:
00956 labels_ohem, bbox_weights_ohem = mx.sym.Custom(op_type='BoxAnnotatorOHEM', num_classes=num_classes,
00957 num_reg_classes=num_reg_classes, roi_per_img=cfg.TRAIN.BATCH_ROIS_OHEM,
00958 cls_score=cls_score, bbox_pred=bbox_pred, labels=label,
00959 bbox_targets=bbox_target, bbox_weights=bbox_weight)
00960 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)
00961 bbox_loss_ = bbox_weights_ohem * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00962 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS_OHEM)
00963 label = labels_ohem
00964 else:
00965 cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=label, normalization='valid', grad_scale=1.0)
00966 bbox_loss_ = bbox_weight * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target))
00967 bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS)
00968
00969
00970 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TRAIN.BATCH_IMAGES, -1, num_classes), name='cls_prob_reshape')
00971 bbox_loss = mx.sym.Reshape(data=bbox_loss, shape=(cfg.TRAIN.BATCH_IMAGES, -1, 4 * num_reg_classes), name='bbox_loss_reshape')
00972 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])
00973 else:
00974 cls_prob = mx.sym.SoftmaxActivation(name='cls_prob', data=cls_score)
00975 cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TEST.BATCH_IMAGES, -1, num_classes),
00976 name='cls_prob_reshape')
00977 bbox_pred = mx.sym.Reshape(data=bbox_pred, shape=(cfg.TEST.BATCH_IMAGES, -1, 4 * num_reg_classes),
00978 name='bbox_pred_reshape')
00979 group = mx.sym.Group([rfcn_cls_offset, cls_prob, bbox_pred])
00980
00981 self.sym = group
00982 return group
00983
00984 def init_weight_rpn(self, cfg, arg_params, aux_params):
00985 arg_params['rpn_conv_3x3_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rpn_conv_3x3_weight'])
00986 arg_params['rpn_conv_3x3_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rpn_conv_3x3_bias'])
00987 arg_params['rpn_cls_score_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rpn_cls_score_weight'])
00988 arg_params['rpn_cls_score_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rpn_cls_score_bias'])
00989 arg_params['rpn_bbox_pred_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rpn_bbox_pred_weight'])
00990 arg_params['rpn_bbox_pred_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rpn_bbox_pred_bias'])
00991
00992 def init_weight_rfcn(self, cfg, arg_params, aux_params):
00993 arg_params['conv_new_1_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['conv_new_1_weight'])
00994 arg_params['conv_new_1_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['conv_new_1_bias'])
00995 arg_params['rfcn_cls_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rfcn_cls_weight'])
00996 arg_params['rfcn_cls_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_cls_bias'])
00997 arg_params['rfcn_bbox_weight'] = mx.random.normal(0, 0.01, shape=self.arg_shape_dict['rfcn_bbox_weight'])
00998 arg_params['rfcn_bbox_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_bbox_bias'])
00999 arg_params['rfcn_cls_offset_t_weight'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_cls_offset_t_weight'])
01000 arg_params['rfcn_cls_offset_t_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_cls_offset_t_bias'])
01001 arg_params['rfcn_bbox_offset_t_weight'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_bbox_offset_t_weight'])
01002 arg_params['rfcn_bbox_offset_t_bias'] = mx.nd.zeros(shape=self.arg_shape_dict['rfcn_bbox_offset_t_bias'])
01003
01004 def init_weight(self, cfg, arg_params, aux_params):
01005 self.init_weight_rpn(cfg, arg_params, aux_params)
01006 self.init_weight_rfcn(cfg, arg_params, aux_params)
01007