本文整理汇总了Python中cntk.abs方法的典型用法代码示例。如果您正苦于以下问题:Python cntk.abs方法的具体用法?Python cntk.abs怎么用?Python cntk.abs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cntk
的用法示例。
在下文中一共展示了cntk.abs方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SmoothL1Loss
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import abs [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)
示例2: test_abs
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import abs [as 别名]
def test_abs():
assert_cntk_ngraph_array_equal(C.abs([-1, 1, -2, 3]))
assert_cntk_ngraph_array_equal(C.abs([[1, -2], [3, -4]]))
assert_cntk_ngraph_array_equal(C.abs([[[1, 2], [-3, 4]], [[1, -2], [3, 4]]]))
示例3: abs
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import abs [as 别名]
def abs(x):
return C.abs(x)
示例4: sign
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import abs [as 别名]
def sign(x):
return x / C.abs(x)
示例5: softsign
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import abs [as 别名]
def softsign(x):
return x / (1 + C.abs(x))
示例6: l1_reg_loss
# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import abs [as 别名]
def l1_reg_loss(output):
# don't need C.abs(output), because output is already non-negative
# use abs() if your desired output could be negative
return C.reduce_mean(output)
#----------------------------------------
# create computational graph and learner
#----------------------------------------