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


Python tensorflow_fold.ForwardDeclaration方法代码示例

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


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

示例1: dynamic_pooling_blk

# 需要导入模块: import tensorflow_fold [as 别名]
# 或者: from tensorflow_fold import ForwardDeclaration [as 别名]
def dynamic_pooling_blk():
    """Input: root node dic
    Output: pooled, TensorType([hyper.conv_dim, ])
    """
    leaf_case = feature_detector_blk()

    pool_fwd = td.ForwardDeclaration(td.PyObjectType(), td.TensorType([hyper.conv_dim, ]))
    pool = td.Composition()
    with pool.scope():
        cur_fea = feature_detector_blk().reads(pool.input)
        children = td.GetItem('children').reads(pool.input)

        mapped = td.Map(pool_fwd()).reads(children)
        summed = td.Reduce(td.Function(tf.maximum)).reads(mapped)
        summed = td.Function(tf.maximum).reads(summed, cur_fea)
        pool.output.reads(summed)
    pool = td.OneOf(lambda x: x['clen'] == 0,
                    {True: leaf_case, False: pool})
    pool_fwd.resolve_to(pool)
    return pool 
开发者ID:Aetf,项目名称:tensorflow-tbcnn,代码行数:22,代码来源:tbcnn.py

示例2: tree_sum_blk

# 需要导入模块: import tensorflow_fold [as 别名]
# 或者: from tensorflow_fold import ForwardDeclaration [as 别名]
def tree_sum_blk(loss_blk):
    # traverse the tree to sum up the loss
    tree_sum_fwd = td.ForwardDeclaration(td.PyObjectType(), td.TensorType([]))
    tree_sum = td.Composition()
    with tree_sum.scope():
        myloss = loss_blk().reads(tree_sum.input)
        children = td.GetItem('children').reads(tree_sum.input)

        mapped = td.Map(tree_sum_fwd()).reads(children)
        summed = td.Reduce(td.Function(tf.add)).reads(mapped)
        summed = td.Function(tf.add).reads(summed, myloss)
        tree_sum.output.reads(summed)
    tree_sum_fwd.resolve_to(tree_sum)
    return tree_sum 
开发者ID:Aetf,项目名称:tensorflow-tbcnn,代码行数:16,代码来源:embedding.py


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