本文整理匯總了Python中cntk.alias方法的典型用法代碼示例。如果您正苦於以下問題:Python cntk.alias方法的具體用法?Python cntk.alias怎麽用?Python cntk.alias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cntk
的用法示例。
在下文中一共展示了cntk.alias方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_proposal_layer
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import alias [as 別名]
def create_proposal_layer(rpn_cls_prob_reshape, rpn_bbox_pred, im_info, cfg, use_native_proposal_layer=False):
layer_config = {}
layer_config["feat_stride"] = cfg["MODEL"].FEATURE_STRIDE
layer_config["scales"] = cfg["DATA"].PROPOSAL_LAYER_SCALES
layer_config["train_pre_nms_topN"] = cfg["TRAIN"].RPN_PRE_NMS_TOP_N
layer_config["train_post_nms_topN"] = cfg["TRAIN"].RPN_POST_NMS_TOP_N
layer_config["train_nms_thresh"] = float(cfg["TRAIN"].RPN_NMS_THRESH)
layer_config["train_min_size"] = float(cfg["TRAIN"].RPN_MIN_SIZE)
layer_config["test_pre_nms_topN"] = cfg["TEST"].RPN_PRE_NMS_TOP_N
layer_config["test_post_nms_topN"] = cfg["TEST"].RPN_POST_NMS_TOP_N
layer_config["test_nms_thresh"] = float(cfg["TEST"].RPN_NMS_THRESH)
layer_config["test_min_size"] = float(cfg["TEST"].RPN_MIN_SIZE)
if use_native_proposal_layer:
cntk.ops.register_native_user_function('ProposalLayerOp',
'Cntk.ProposalLayerLib-' + cntk.__version__.rstrip('+'),
'CreateProposalLayer')
rpn_rois_raw = ops.native_user_function('ProposalLayerOp', [rpn_cls_prob_reshape, rpn_bbox_pred, im_info],
layer_config, 'native_proposal_layer')
else:
rpn_rois_raw = user_function(ProposalLayer(rpn_cls_prob_reshape, rpn_bbox_pred, im_info, layer_config))
return alias(rpn_rois_raw, name='rpn_rois')
示例2: create_proposal_target_layer
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import alias [as 別名]
def create_proposal_target_layer(rpn_rois, scaled_gt_boxes, num_classes):
'''
Creates a proposal target layer that is used for training an object detection network as proposed in the "Faster R-CNN" paper:
Shaoqing Ren and Kaiming He and Ross Girshick and Jian Sun:
"Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks"
Assigns object detection proposals to ground-truth targets.
Produces proposal classification labels and bounding-box regression targets.
It also adds gt_boxes to candidates and samples fg and bg rois for training.
Args:
rpn_rois: The proposed ROIs, e.g. from a region proposal network
scaled_gt_boxes: The ground truth boxes as (x1, y1, x2, y2, label). Coordinates are absolute pixels wrt. the input image.
num_classes: The number of classes in the data set
Returns:
rpn_target_rois - a set of rois containing the ground truth and a number of sampled fg and bg ROIs
label_targets - the target labels for the rois
bbox_targets - the regression coefficient targets for the rois
bbox_inside_weights - the weights for the regression loss
'''
ptl_param_string = "'num_classes': {}".format(num_classes)
ptl = user_function(ProposalTargetLayer(rpn_rois, scaled_gt_boxes, param_str=ptl_param_string))
# use an alias if you need to access the outputs, e.g., when cloning a trained network
rois = alias(ptl.outputs[0], name='rpn_target_rois')
label_targets = ptl.outputs[1]
bbox_targets = ptl.outputs[2]
bbox_inside_weights = ptl.outputs[3]
return rois, label_targets, bbox_targets, bbox_inside_weights
示例3: identity
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import alias [as 別名]
def identity(x, name=None):
if name is None:
name = '%s_alias' % x.name
return C.alias(x, name=name)
示例4: conv_from_weights
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import alias [as 別名]
def conv_from_weights(x, weights, bias=None, padding=True, name=""):
""" weights is a numpy array """
k = C.parameter(shape=weights.shape, init=weights)
y = C.convolution(k, x, auto_padding=[False, padding, padding])
if bias:
b = C.parameter(shape=bias.shape, init=bias)
y = y + bias
y = C.alias(y, name=name)
return y
# bi-directional recurrence function op
# fwd, bwd: a recurrent op, LSTM or GRU
示例5: create_proposal_target_layer
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import alias [as 別名]
def create_proposal_target_layer(rpn_rois, scaled_gt_boxes, cfg):
'''
Creates a proposal target layer that is used for training an object detection network as proposed in the "Faster R-CNN" paper:
Shaoqing Ren and Kaiming He and Ross Girshick and Jian Sun:
"Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks"
Assigns object detection proposals to ground-truth targets.
Produces proposal classification labels and bounding-box regression targets.
It also adds gt_boxes to candidates and samples fg and bg rois for training.
Args:
rpn_rois: The proposed ROIs, e.g. from a region proposal network
scaled_gt_boxes: The ground truth boxes as (x1, y1, x2, y2, label). Coordinates are absolute pixels wrt. the input image.
num_classes: The number of classes in the data set
Returns:
rpn_target_rois - a set of rois containing the ground truth and a number of sampled fg and bg ROIs
label_targets - the target labels for the rois
bbox_targets - the regression coefficient targets for the rois
bbox_inside_weights - the weights for the regression loss
'''
ptl_param_string = "'num_classes': {}".format(cfg["DATA"].NUM_CLASSES)
ptl = user_function(ProposalTargetLayer(rpn_rois, scaled_gt_boxes,
batch_size=cfg.NUM_ROI_PROPOSALS,
fg_fraction=cfg["TRAIN"].FG_FRACTION,
normalize_targets=cfg.BBOX_NORMALIZE_TARGETS,
normalize_means=cfg.BBOX_NORMALIZE_MEANS,
normalize_stds=cfg.BBOX_NORMALIZE_STDS,
fg_thresh=cfg["TRAIN"].FG_THRESH,
bg_thresh_hi=cfg["TRAIN"].BG_THRESH_HI,
bg_thresh_lo=cfg["TRAIN"].BG_THRESH_LO,
param_str=ptl_param_string))
# use an alias if you need to access the outputs, e.g., when cloning a trained network
rois = alias(ptl.outputs[0], name='rpn_target_rois')
label_targets = ptl.outputs[1]
bbox_targets = ptl.outputs[2]
bbox_inside_weights = ptl.outputs[3]
return rois, label_targets, bbox_targets, bbox_inside_weights
示例6: identity
# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import alias [as 別名]
def identity(x):
return C.alias(x, name=('%s_alias' % (x.name)))