mx-rcnn
mx-rcnn copied to clipboard
rpn
hello, can you explain more about the num_anchors, box_inside_weight and bbox outside weight here? And I am marked the cls_prob output shape #(1, 2, 1764) provided data=(1, 3, 224, 224), is that right? Seems a little strange to me.
def get_vgg_rpn(num_classes=21, num_anchors=9):
data = mx.symbol.Variable(name="data")
label = mx.symbol.Variable(name='label')
bbox_target = mx.symbol.Variable(name='bbox_target')
bbox_inside_weight = mx.symbol.Variable(name='bbox_inside_weight')
bbox_outside_weight = mx.symbol.Variable(name='bbox_outside_weight')
# shared convolutional layers
relu5_3 = get_vgg_conv(data)
#(1, 512, 14, 14)
# RPN
rpn_conv = mx.symbol.Convolution(
data=relu5_3, kernel=(3, 3), pad=(1, 1), num_filter=512, name="rpn_conv_3x3", workspace=2048)
rpn_relu = mx.symbol.Activation(data=rpn_conv, act_type="relu", name="rpn_relu")
rpn_cls_score = mx.symbol.Convolution(
data=rpn_relu, kernel=(1, 1), pad=(0, 0), num_filter=2 * num_anchors, name="rpn_cls_score", workspace=2048)
##(1, 18, 14, 14)
rpn_bbox_pred = mx.symbol.Convolution(
data=rpn_relu, kernel=(1, 1), pad=(0, 0), num_filter=4 * num_anchors, name="rpn_bbox_pred", workspace=2048)
##(1, 36, 14, 14)
# prepare rpn data
rpn_cls_score_reshape = mx.symbol.Reshape(
data=rpn_cls_score, shape=(0, 2, -1), name="rpn_cls_score_reshape")
#(1, 2, 1764)
# classification
cls_prob = mx.symbol.SoftmaxOutput(data=rpn_cls_score_reshape, label=label, multi_output=True,
normalization='valid', use_ignore=True, ignore_label=-1, name="cls_prob")
#(1, 2, 1764)
# bounding box regression
bbox_loss_ = bbox_outside_weight * \
mx.symbol.smooth_l1(name='bbox_loss_', scalar=3.0,
data=bbox_inside_weight * (rpn_bbox_pred - bbox_target))
bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_)
# group output
group = mx.symbol.Group([cls_prob, bbox_loss])
return group`
please look into code of AnchorLoader