當前位置: 首頁>>代碼示例>>Python>>正文


Python cntk.less方法代碼示例

本文整理匯總了Python中cntk.less方法的典型用法代碼示例。如果您正苦於以下問題:Python cntk.less方法的具體用法?Python cntk.less怎麽用?Python cntk.less使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cntk的用法示例。


在下文中一共展示了cntk.less方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: SmoothL1Loss

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import less [as 別名]
def SmoothL1Loss(sigma, bbox_pred, bbox_targets, bbox_inside_weights, bbox_outside_weights):
    """
        From https://github.com/smallcorgi/Faster-RCNN_TF/blob/master/lib/fast_rcnn/train.py

        ResultLoss = outside_weights * SmoothL1(inside_weights * (bbox_pred - bbox_targets))
        SmoothL1(x) = 0.5 * (sigma * x)^2,    if |x| < 1 / sigma^2
                        |x| - 0.5 / sigma^2,    otherwise
    """
    sigma2 = sigma * sigma

    inside_mul_abs = C.abs(C.element_times(bbox_inside_weights, C.minus(bbox_pred, bbox_targets)))

    smooth_l1_sign = C.less(inside_mul_abs, 1.0 / sigma2)
    smooth_l1_option1 = C.element_times(C.element_times(inside_mul_abs, inside_mul_abs), 0.5 * sigma2)
    smooth_l1_option2 = C.minus(inside_mul_abs, 0.5 / sigma2)
    smooth_l1_result = C.plus(C.element_times(smooth_l1_option1, smooth_l1_sign),
                              C.element_times(smooth_l1_option2, C.minus(1.0, smooth_l1_sign)))

    return C.element_times(bbox_outside_weights, smooth_l1_result) 
開發者ID:karolzak,項目名稱:cntk-python-web-service-on-azure,代碼行數:21,代碼來源:cntk_smoothL1_loss.py

示例2: switch

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import less [as 別名]
def switch(condition, then_expression, else_expression):
    ndim_cond = ndim(condition)
    ndim_expr = ndim(then_expression)
    if ndim_cond > ndim_expr:
        raise ValueError('Rank of condition should be less'
                         ' than or equal to rank of then and'
                         ' else expressions. ndim(condition)=' +
                         str(ndim_cond) + ', ndim(then_expression)'
                         '=' + str(ndim_expr))
    elif ndim_cond < ndim_expr:
        shape_expr = int_shape(then_expression)
        ndim_diff = ndim_expr - ndim_cond
        for i in range(ndim_diff):
            condition = expand_dims(condition)
            condition = tile(condition, shape_expr[ndim_cond + i])
    return C.element_select(condition,
                            then_expression,
                            else_expression) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:20,代碼來源:cntk_backend.py

示例3: switch

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import less [as 別名]
def switch(condition, then_expression, else_expression):
    ndim_cond = ndim(condition)
    ndim_expr = ndim(then_expression)
    if ndim_cond > ndim_expr:
        raise ValueError('Rank of condition should be less'
                         ' than or equal to rank of then and'
                         ' else expressions. ndim(condition)=' +
                         str(cond_ndim) + ', ndim(then_expression)'
                         '=' + str(expr_ndim))
    elif ndim_cond < ndim_expr:
        shape_expr = int_shape(then_expression)
        ndim_diff = ndim_expr - ndim_cond
        for i in range(ndim_diff):
            condition = expand_dims(condition)
            condition = tile(condition, shape_expr[ndim_cond + i])
    return C.element_select(condition,
                            then_expression,
                            else_expression) 
開發者ID:sheffieldnlp,項目名稱:deepQuest,代碼行數:20,代碼來源:cntk_backend.py

示例4: less

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import less [as 別名]
def less(x, y):
    return C.less(x, y) 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:4,代碼來源:cntk_backend.py


注:本文中的cntk.less方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。