当前位置: 首页>>代码示例>>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;未经允许,请勿转载。