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


Python cntk.element_times方法代码示例

本文整理汇总了Python中cntk.element_times方法的典型用法代码示例。如果您正苦于以下问题:Python cntk.element_times方法的具体用法?Python cntk.element_times怎么用?Python cntk.element_times使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cntk的用法示例。


在下文中一共展示了cntk.element_times方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SmoothL1Loss

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import element_times [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: test_element_times_1

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import element_times [as 别名]
def test_element_times_1():
    cntk_op = C.element_times([1, 2, 3], [4, 5, 6])
    cntk_ret = cntk_op.eval()

    ng_op, _ = CNTKImporter().import_model(cntk_op)
    ng_ret = ng.transformers.make_transformer().computation(ng_op)()

    assert np.array_equal(cntk_ret, ng_ret) 
开发者ID:NervanaSystems,项目名称:ngraph-python,代码行数:10,代码来源:test_ops_binary.py

示例3: test_element_times_2

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import element_times [as 别名]
def test_element_times_2():
    cntk_op = C.element_times([[1, 2, 3], [4, 5, 6]], [7, 8, 9])
    cntk_ret = cntk_op.eval()

    ng_op, _ = CNTKImporter().import_model(cntk_op)
    ng_ret = ng.transformers.make_transformer().computation(ng_op)()

    assert np.array_equal(cntk_ret, ng_ret) 
开发者ID:NervanaSystems,项目名称:ngraph-python,代码行数:10,代码来源:test_ops_binary.py

示例4: test_element_times_3

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import element_times [as 别名]
def test_element_times_3():
    cntk_op = C.element_times([1, 2, 3], [[4, 5, 6], [7, 8, 9]])
    cntk_ret = cntk_op.eval()

    ng_op, _ = CNTKImporter().import_model(cntk_op)
    ng_ret = ng.transformers.make_transformer().computation(ng_op)()

    assert np.array_equal(cntk_ret, ng_ret) 
开发者ID:NervanaSystems,项目名称:ngraph-python,代码行数:10,代码来源:test_ops_binary.py

示例5: std_normalized_l2_loss

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import element_times [as 别名]
def std_normalized_l2_loss(output, target):
    std_inv = np.array([6.6864805402, 5.2904440280, 3.7165409939, 4.1421640454, 8.1537399389, 7.0312877415, 2.6712380967,
                        2.6372177876, 8.4253649884, 6.7482162880, 9.0849960354, 10.2624412692, 3.1325531319, 3.1091179819,
                        2.7337937590, 2.7336441031, 4.3542467871, 5.4896293687, 6.2003761588, 3.1290341469, 5.7677042738,
                        11.5460919611, 9.9926451700, 5.4259818848, 20.5060642486, 4.7692101480, 3.1681517575, 3.8582905289,
                        3.4222250436, 4.6828286809, 3.0070785113, 2.8936539301, 4.0649030157, 25.3068458731, 6.0030623160,
                        3.1151977458, 7.7773542649, 6.2057372469, 9.9494258692, 4.6865422850, 5.3300697628, 2.7722027974,
                        4.0658663003, 18.1101618617, 3.5390113731, 2.7794520068], dtype=np.float32)
    weights = C.constant(value=std_inv) #.reshape((1, label_dim)))
    dif = output - target
    ret = C.reduce_mean(C.square(C.element_times(dif, weights)))
    return ret 
开发者ID:haixpham,项目名称:end2end_AU_speech,代码行数:14,代码来源:train_end2end.py


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