当前位置: 首页>>代码示例>>Python>>正文


Python cntk.alias方法代码示例

本文整理汇总了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') 
开发者ID:Esri,项目名称:raster-deep-learning,代码行数:27,代码来源:rpn_helpers.py

示例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 
开发者ID:karolzak,项目名称:cntk-python-web-service-on-azure,代码行数:34,代码来源:rpn_helpers.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:6,代码来源:cntk_backend.py

示例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 
开发者ID:haixpham,项目名称:end2end_AU_speech,代码行数:15,代码来源:LayerUtils.py

示例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 
开发者ID:Esri,项目名称:raster-deep-learning,代码行数:43,代码来源:rpn_helpers.py

示例6: identity

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import alias [as 别名]
def identity(x):
    return C.alias(x, name=('%s_alias' % (x.name))) 
开发者ID:sheffieldnlp,项目名称:deepQuest,代码行数:4,代码来源:cntk_backend.py


注:本文中的cntk.alias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。