Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpn #3

Open
GeorgeXia1828 opened this issue Sep 27, 2016 · 1 comment
Open

rpn #3

GeorgeXia1828 opened this issue Sep 27, 2016 · 1 comment

Comments

@GeorgeXia1828
Copy link

GeorgeXia1828 commented Sep 27, 2016

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`
@tornadomeet
Copy link
Owner

please look into code of AnchorLoader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants