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


Python cntk.reduce_mean方法代码示例

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


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

示例1: _moments

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import reduce_mean [as 别名]
def _moments(x, axes=None, shift=None, keep_dims=False):
    _axes = tuple(axes)
    if shift is None:
        shift = x
        # Compute true mean while keeping the dims for proper broadcasting.
        for axis in _axes:
            shift = C.reduce_mean(shift, axis=axis)

    shift = C.stop_gradient(shift)
    shifted_mean = C.minus(x, shift)
    for axis in _axes:
        shifted_mean = C.reduce_mean(shifted_mean, axis=axis)

    variance_mean = C.square(C.minus(x, shift))
    for axis in _axes:
        variance_mean = C.reduce_mean(variance_mean, axis=axis)

    variance = C.minus(variance_mean, C.square(shifted_mean))
    mean = C.plus(shifted_mean, shift)

    if not keep_dims:
        mean = squeeze(mean, _axes)
        variance = squeeze(variance, _axes)

    return mean, variance 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:27,代码来源:cntk_backend.py

示例2: test_reduce_mean

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import reduce_mean [as 别名]
def test_reduce_mean():
    data = np.array([[[5, 1], [20, 2]], [[30, 1], [40, 2]], [[55, 1], [60, 2]]], dtype=np.float32)

    assert_cntk_ngraph_flat_equal(C.reduce_mean([1, 0], 0))
    assert_cntk_ngraph_flat_equal(C.reduce_mean([[1., 1.], [3., 5.]], 0))
    assert_cntk_ngraph_flat_equal(C.reduce_mean([[1., 1.], [3., 5.]], 1))
    assert_cntk_ngraph_flat_equal(C.reduce_mean([[1., 1.], [3., 5.]], -1))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, 0))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, 1))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, 2))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, -1))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, (0, 1)))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, (0, 2)))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, (1, 2)))
    assert_cntk_ngraph_flat_equal(C.reduce_mean(data, (-1, -2))) 
开发者ID:NervanaSystems,项目名称:ngraph-python,代码行数:17,代码来源:test_ops_unary.py

示例3: mean

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import reduce_mean [as 别名]
def mean(x, axis=None, keepdims=False):
    axis = _normalize_axis(axis, x)
    output = _reduce_on_axis(x, axis, 'reduce_mean')

    return _remove_dims(output, axis, keepdims) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:7,代码来源:cntk_backend.py

示例4: classification_error

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import reduce_mean [as 别名]
def classification_error(target, output, axis=-1):
    return C.ops.reduce_mean(
        C.equal(
            argmax(
                output,
                axis=-1),
            argmax(
                target,
                axis=-1)),
        axis=C.Axis.all_axes()) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:12,代码来源:cntk_backend.py

示例5: l2_loss

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import reduce_mean [as 别名]
def l2_loss(output, target):
    return C.reduce_mean(C.square(output - target)) 
开发者ID:haixpham,项目名称:end2end_AU_speech,代码行数:4,代码来源:train_end2end.py

示例6: std_normalized_l2_loss

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

示例7: l1_reg_loss

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import reduce_mean [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
#---------------------------------------- 
开发者ID:haixpham,项目名称:end2end_AU_speech,代码行数:11,代码来源:train_end2end.py


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