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


Python theano.foldr方法代碼示例

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


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

示例1: foldr

# 需要導入模塊: import theano [as 別名]
# 或者: from theano import foldr [as 別名]
def foldr(fn, elems, initializer=None, name=None):
    '''Reduce elems using fn to combine them from right to left.

    # Arguments
        fn: Callable that will be called upon each element in elems and an
            accumulator, for instance lambda acc, x: acc + x
        elems: tensor
        initializer: The first value used (elems[-1] in case of None)
        name: A string name for the foldr node in the graph

    # Returns
        Same type and shape as initializer
    '''
    if initializer is None:
        initializer = elems[-1]
        elems = elems[:-1]

    # We need to change the order of the arguments because theano accepts x as
    # first parameter and accumulator as second
    fn2 = lambda x, acc: fn(acc, x)

    return theano.foldr(fn2, elems, initializer, name=name)[0] 
開發者ID:lingluodlut,項目名稱:Att-ChemdNER,代碼行數:24,代碼來源:theano_backend.py

示例2: foldr

# 需要導入模塊: import theano [as 別名]
# 或者: from theano import foldr [as 別名]
def foldr(fn, elems, initializer=None, name=None):
    """Reduce elems using fn to combine them from right to left.

    # Arguments
        fn: Callable that will be called upon each element in elems and an
            accumulator, for instance lambda acc, x: acc + x
        elems: tensor
        initializer: The first value used (elems[-1] in case of None)
        name: A string name for the foldr node in the graph

    # Returns
        Same type and shape as initializer
    """
    if initializer is None:
        initializer = elems[-1]
        elems = elems[:-1]

    # We need to change the order of the arguments because theano accepts x as
    # first parameter and accumulator as second
    return theano.foldr(lambda x, acc: fn(acc, x),
                        elems, initializer, name=name)[0] 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:23,代碼來源:theano_backend.py

示例3: foldr

# 需要導入模塊: import theano [as 別名]
# 或者: from theano import foldr [as 別名]
def foldr(fn, elems, initializer=None, name=None):
    """Reduce elems using fn to combine them from right to left.

    # Arguments
        fn: Callable that will be called upon each element in elems and an
            accumulator, for instance lambda acc, x: acc + x
        elems: tensor
        initializer: The first value used (elems[-1] in case of None)
        name: A string name for the foldr node in the graph

    # Returns
        Same type and shape as initializer
    """
    if initializer is None:
        initializer = elems[-1]
        elems = elems[:-1]

    # We need to change the order of the arguments because theano accepts x as
    # first parameter and accumulator as second
    fn2 = lambda x, acc: fn(acc, x)

    return theano.foldr(fn2, elems, initializer, name=name)[0] 
開發者ID:sunilmallya,項目名稱:keras-lambda,代碼行數:24,代碼來源:theano_backend.py


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