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


Python cntk.sqrt方法代碼示例

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


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

示例1: batch_normalization

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import sqrt [as 別名]
def batch_normalization(x, mean, var, beta, gamma, axis=-1, epsilon=1e-3):
    # The mean / var / beta / gamma may be processed by broadcast
    # so it may have an extra batch axis with 1, it is not needed
    # in cntk, need to remove those dummy axis.
    if ndim(mean) == ndim(x) and shape(mean)[0] == 1:
        mean = _reshape_dummy_dim(mean, [0])
    if ndim(var) == ndim(x) and shape(var)[0] == 1:
        var = _reshape_dummy_dim(var, [0])

    if gamma is None:
        gamma = ones_like(var)
    elif ndim(gamma) == ndim(x) and shape(gamma)[0] == 1:
        gamma = _reshape_dummy_dim(gamma, [0])

    if beta is None:
        beta = zeros_like(mean)
    elif ndim(beta) == ndim(x) and shape(beta)[0] == 1:
        beta = _reshape_dummy_dim(beta, [0])

    return (x - mean) / C.sqrt(var + epsilon) * gamma + beta 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:22,代碼來源:cntk_backend.py

示例2: _layer_BatchNorm

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import sqrt [as 別名]
def _layer_BatchNorm(self):
        self.add_body(0, """
def batch_normalization(input, name, epsilon, **kwargs):
    mean = cntk.Parameter(init = __weights_dict[name]['mean'],
        name = name + "_mean")
    var = cntk.Parameter(init = __weights_dict[name]['var'],
        name = name + "_var")

    layer = (input - mean) / cntk.sqrt(var + epsilon)
    if 'scale' in __weights_dict[name]:
        scale = cntk.Parameter(init = __weights_dict[name]['scale'],
            name = name + "_scale")
        layer = scale * layer

    if 'bias' in __weights_dict[name]:
        bias = cntk.Parameter(init = __weights_dict[name]['bias'],
            name = name + "_bias")
        layer = layer + bias

    return layer
""") 
開發者ID:microsoft,項目名稱:MMdnn,代碼行數:23,代碼來源:cntk_emitter.py

示例3: batch_normalization

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import sqrt [as 別名]
def batch_normalization(x, mean, var, beta, gamma, epsilon=1e-3):
    # The mean / var / beta / gamma may be processed by broadcast
    # so it may have an extra batch axis with 1, it is not needed
    # in cntk, need to remove those dummy axis.
    if ndim(mean) == ndim(x) and shape(mean)[0] == 1:
        mean = _reshape_dummy_dim(mean, [0])
    if ndim(var) == ndim(x) and shape(var)[0] == 1:
        var = _reshape_dummy_dim(var, [0])

    if gamma is None:
        gamma = ones_like(var)
    elif ndim(gamma) == ndim(x) and shape(gamma)[0] == 1:
        gamma = _reshape_dummy_dim(gamma, [0])

    if beta is None:
        beta = zeros_like(mean)
    elif ndim(beta) == ndim(x) and shape(beta)[0] == 1:
        beta = _reshape_dummy_dim(beta, [0])

    return (x - mean) / (C.sqrt(var) + epsilon) * gamma + beta 
開發者ID:hello-sea,項目名稱:DeepLearning_Wavelet-LSTM,代碼行數:22,代碼來源:cntk_backend.py

示例4: batch_normalization

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import sqrt [as 別名]
def batch_normalization(x, mean, var, beta, gamma, epsilon=1e-3):
    # The mean / var / beta / gamma may be processed by broadcast
    # so it may have an extra batch axis with 1, it is not needed
    # in cntk, need to remove those dummy axis.
    if ndim(mean) == ndim(x) and shape(mean)[0] == 1:
        mean = _reshape_dummy_dim(mean, [0])
    if ndim(var) == ndim(x) and shape(var)[0] == 1:
        var = _reshape_dummy_dim(var, [0])

    if gamma is None:
        gamma = ones_like(var)
    elif ndim(gamma) == ndim(x) and shape(gamma)[0] == 1:
        gamma = _reshape_dummy_dim(gamma, [0])

    if beta is None:
        beta = zeros_like(mean)
    elif ndim(beta) == ndim(x) and shape(beta)[0] == 1:
        beta = _reshape_dummy_dim(beta, [0])

    return gamma * ((x - mean) / C.sqrt(var + epsilon)) + beta 
開發者ID:sheffieldnlp,項目名稱:deepQuest,代碼行數:22,代碼來源:cntk_backend.py

示例5: test_sqrt

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import sqrt [as 別名]
def test_sqrt():
    assert_cntk_ngraph_isclose(C.sqrt([0., 4.]))
    assert_cntk_ngraph_isclose(C.sqrt([[1, 2], [3, 4]]))
    assert_cntk_ngraph_isclose(C.sqrt([[[1, 2], [3, 4]], [[1, 2], [3, 4]]])) 
開發者ID:NervanaSystems,項目名稱:ngraph-python,代碼行數:6,代碼來源:test_ops_unary.py

示例6: std

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

示例7: sqrt

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

示例8: l2_normalize

# 需要導入模塊: import cntk [as 別名]
# 或者: from cntk import sqrt [as 別名]
def l2_normalize(x, axis=None):
    axis = [axis]
    axis = _normalize_axis(axis, x)
    norm = C.sqrt(C.reduce_sum(C.square(x), axis=axis[0]))
    return x / norm 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:7,代碼來源:cntk_backend.py


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