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


Python cntk.log方法代码示例

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


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

示例1: test_log

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import log [as 别名]
def test_log():
    assert_cntk_ngraph_array_equal(C.log([1., 2.]))
    assert_cntk_ngraph_array_equal(C.log([[1, 2], [3, 4]]))
    assert_cntk_ngraph_array_equal(C.log([[[1, 2], [3, 4]], [[1, 2], [3, 4]]])) 
开发者ID:NervanaSystems,项目名称:ngraph-python,代码行数:6,代码来源:test_ops_unary.py

示例2: logsumexp

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import log [as 别名]
def logsumexp(x, axis=None, keepdims=False):
    return log(sum(exp(x), axis=axis, keepdims=keepdims)) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:4,代码来源:cntk_backend.py

示例3: log

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import log [as 别名]
def log(x):
    return C.log(x) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:4,代码来源:cntk_backend.py

示例4: binary_crossentropy

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import log [as 别名]
def binary_crossentropy(target, output, from_logits=False):
    if from_logits:
        output = C.sigmoid(output)
    output = C.clip(output, epsilon(), 1.0 - epsilon())
    output = -target * C.log(output) - (1.0 - target) * C.log(1.0 - output)
    return output 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:cntk_backend.py

示例5: categorical_crossentropy

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import log [as 别名]
def categorical_crossentropy(target, output, from_logits=False, axis=-1):
    # Here, unlike other backends, the tensors lack a batch dimension:
    axis_without_batch = -1 if axis == -1 else axis - 1
    output_dimensions = list(range(len(output.shape)))
    if axis_without_batch != -1 and axis_without_batch not in output_dimensions:
        raise ValueError(
            '{}{}{}'.format(
                'Unexpected channels axis {}. '.format(axis_without_batch),
                'Expected to be -1 or one of the axes of `output`, ',
                'which has {} dimensions.'.format(len(output.shape))))
    # If the channels are not in the last axis, move them to be there:
    if axis_without_batch != -1 and axis_without_batch != output_dimensions[-1]:
        permutation = output_dimensions[:axis_without_batch]
        permutation += output_dimensions[axis_without_batch + 1:]
        permutation += [axis_without_batch]
        output = C.transpose(output, permutation)
        target = C.transpose(target, permutation)
    if from_logits:
        result = C.cross_entropy_with_softmax(output, target)
        # cntk's result shape is (batch, 1), while keras expect (batch, )
        return C.reshape(result, ())
    else:
        # scale preds so that the class probas of each sample sum to 1
        output /= C.reduce_sum(output, axis=-1)
        # avoid numerical instability with epsilon clipping
        output = C.clip(output, epsilon(), 1.0 - epsilon())
        return -sum(target * C.log(output), axis=-1) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:29,代码来源:cntk_backend.py

示例6: categorical_crossentropy

# 需要导入模块: import cntk [as 别名]
# 或者: from cntk import log [as 别名]
def categorical_crossentropy(target, output, from_logits=False):
    if from_logits:
        result = C.cross_entropy_with_softmax(output, target)
        # cntk's result shape is (batch, 1), while keras expect (batch, )
        return C.reshape(result, ())
    else:
        # scale preds so that the class probas of each sample sum to 1
        output /= C.reduce_sum(output, axis=-1)
        # avoid numerical instability with epsilon clipping
        output = C.clip(output, epsilon(), 1.0 - epsilon())
        return -sum(target * C.log(output), axis=-1) 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:13,代码来源:cntk_backend.py


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