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


rail_object_detector
Author(s):
autogenerated on Sat Jun 8 2019 20:26:30