【问题标题】:Tensorflow how to dump the result placement algorithmTensorFlow 如何转储结果放置算法
【发布时间】:2017-08-17 22:21:03
【问题描述】:
  1. 我对模型并行性很好奇,我已经阅读了来自Yaroslav Bulatov 的代码。在那个例子中,我们应该手动将我们的模型(或者在 tensorflow 中我们称为 Graph)分区到不同的分区(left_network 和 right_network)。 所以,我想知道我是否必须手动进行分区,simple_placer.ccgraph_partition.cc 对整个图表做了什么?而且我仍然不清楚。

  2. 在我看来(如果有任何错误请告诉我): 如果图有8个分区(子图),可以看成8个job,4个worker,那么partition如何分配给worker可以通过:

    • 通过tf.device() 显式注释,或
    • 分布式训练,tf.train.replica_device_setter()

      在参数服务器之间共享变量,否则将所有 工作设备上的操作

但是图是如何划分分区的呢? 我想跟踪子图(操作节点集)是什么样的? 我可以转储结果还是需要跟踪/修改哪个代码文件?

如果有任何概念错误或含糊,请告诉我。 我是这方面的菜鸟,任何意见都表示赞赏。

  1. 在下面的代码中,matmul 是一个操作节点,它会被划分为 不同的工作?

    y_ = tf.placeholder(tf.float32, [None, 10])
    x = tf.placeholder(tf.float32, [None, 784])
    W = tf.Variable(tf.zeros([784, 10]))
    b = tf.Variable(tf.zeros([10]))
    y = tf.matmul(x, W)  + b
    

【问题讨论】:

    标签: algorithm tensorflow


    【解决方案1】:

    你可以在调用tf.Session.run()时传递额外的选项来得到放置算法的结果

    # ...
    y = tf.matmul(x, W) + b
    
    sess = tf.Session()
    options = tf.RunOptions(output_partition_graphs=True)
    metadata = tf.RunMetadata()
    
    sess.run(y, options=options, run_metadata=metadata)
    
    # `metadata` now contains information about what happened during the `run()` call.
    for partition in metadata.partition_graphs:
    
      # `partition` is a `tf.GraphDef` representing all the nodes that ran on a single
      # device. All nodes in `partition` have the same `device` value.
      device = partition.node[0].device
    
      for node in partition.node:
        # e.g. print each node or store it in a dictionary for further analysis.
        # ...
    

    【讨论】:

    • 非常有用的代码 sn-p。我仍然想知道有没有办法在插入发送/接收 OP 后将图形转储为 PB?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 2017-07-05
    • 2010-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多