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


Python graph_editor.get_forward_walk_ops方法代码示例

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


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

示例1: tf_toposort

# 需要导入模块: from tensorflow.contrib import graph_editor [as 别名]
# 或者: from tensorflow.contrib.graph_editor import get_forward_walk_ops [as 别名]
def tf_toposort(ts, within_ops=None):
    all_ops = ge.get_forward_walk_ops(
        [x.op for x in ts], within_ops=within_ops)

    deps = {}
    for op in all_ops:
        for o in op.outputs:
            deps[o] = set(op.inputs)
    sorted_ts = toposort(deps)

    # only keep the tensors from our original list
    ts_sorted_lists = []
    for l in sorted_ts:
        keep = list(set(l).intersection(ts))
        if keep:
            ts_sorted_lists.append(keep)

    return ts_sorted_lists 
开发者ID:openai,项目名称:glow,代码行数:20,代码来源:memory_saving_gradients.py

示例2: tf_toposort

# 需要导入模块: from tensorflow.contrib import graph_editor [as 别名]
# 或者: from tensorflow.contrib.graph_editor import get_forward_walk_ops [as 别名]
def tf_toposort(ts, within_ops=None):
    all_ops = ge.get_forward_walk_ops([x.op for x in ts], within_ops=within_ops)

    deps = {}
    for op in all_ops:
        for o in op.outputs:
            deps[o] = set(op.inputs)
    sorted_ts = toposort(deps)

    # only keep the tensors from our original list
    ts_sorted_lists = []
    for l in sorted_ts:
        keep = list(set(l).intersection(ts))
        if keep:
            ts_sorted_lists.append(keep)

    return ts_sorted_lists 
开发者ID:cybertronai,项目名称:gradient-checkpointing,代码行数:19,代码来源:memory_saving_gradients.py

示例3: test_resnet_structure

# 需要导入模块: from tensorflow.contrib import graph_editor [as 别名]
# 或者: from tensorflow.contrib.graph_editor import get_forward_walk_ops [as 别名]
def test_resnet_structure():
  """sanity check on TF resnet structure."""
  tf.reset_default_graph()
  nodes = util.make_resnet(3)
  all_ops = ge.get_forward_walk_ops(seed_ops=nodes[0].op)
  desired_graph = {0: [1, 2], 1: [2], 2: [3, 4], 3: [4]}
  actual_graph = util.tf_ops_to_graph(all_ops)
  assert(util.graphs_isomorphic(actual_graph, desired_graph)) 
开发者ID:cybertronai,项目名称:gradient-checkpointing,代码行数:10,代码来源:util_test.py

示例4: test_articulation_points_resnet

# 需要导入模块: from tensorflow.contrib import graph_editor [as 别名]
# 或者: from tensorflow.contrib.graph_editor import get_forward_walk_ops [as 别名]
def test_articulation_points_resnet():
  """Make sure articulation points are found correctly in resnet."""
  tf.reset_default_graph()
  nodes = util.make_resnet(3)
  all_ops = ge.get_forward_walk_ops(seed_ops=nodes[0].op)
  graph = nx.Graph(util.tf_ops_to_graph(all_ops))
  assert util.set_equal(util.format_ops(nx.articulation_points(graph)),
                        ['a01_add'])
  
  tf.reset_default_graph()
  nodes = util.make_resnet(4)
  all_ops = ge.get_forward_walk_ops(seed_ops=nodes[0].op)
  graph = nx.Graph(util.tf_ops_to_graph(all_ops))
  assert util.set_equal(util.format_ops(nx.articulation_points(graph)),
                        ['a01_add', 'a02_add']) 
开发者ID:cybertronai,项目名称:gradient-checkpointing,代码行数:17,代码来源:util_test.py


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