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


Python NodeStepper.sorted_transitive_closure方法代碼示例

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


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

示例1: testContWithPlaceholders

# 需要導入模塊: from tensorflow.python.debug.stepper import NodeStepper [as 別名]
# 或者: from tensorflow.python.debug.stepper.NodeStepper import sorted_transitive_closure [as 別名]
  def testContWithPlaceholders(self):
    stepper = NodeStepper(
        self.sess,
        self.y,
        feed_dict={
            self.ph0: [[1.0, 2.0], [-3.0, 5.0]],
            self.ph1: [[-1.0], [0.5]]
        })

    self.assertEqual(["ph0:0", "ph1:0", "x:0", "y:0"],
                     stepper.sorted_transitive_closure())

    result = stepper.cont(self.x)
    self.assertAllClose([[0.0], [5.5]], result)
    self.assertEqual({
        "ph0:0": NodeStepper.FEED_TYPE_CLIENT,
        "ph1:0": NodeStepper.FEED_TYPE_CLIENT,
    }, stepper.last_feed_types())

    self.assertEqual(["x:0"], stepper.handle_names())

    result = stepper.cont(self.y)
    self.assertAllClose([[-1.0], [6.0]], result)
    self.assertEqual({
        "x:0": NodeStepper.FEED_TYPE_HANDLE,
        "ph1:0": NodeStepper.FEED_TYPE_CLIENT,
    }, stepper.last_feed_types())
開發者ID:brchiu,項目名稱:tensorflow,代碼行數:29,代碼來源:stepper_test.py

示例2: testContToNodeWithOutputTensors

# 需要導入模塊: from tensorflow.python.debug.stepper import NodeStepper [as 別名]
# 或者: from tensorflow.python.debug.stepper.NodeStepper import sorted_transitive_closure [as 別名]
  def testContToNodeWithOutputTensors(self):
    """cont() to an op should cache its output tensors if appropriate."""

    stepper = NodeStepper(self.sess, "optim")

    # In the transitive closure of the stepper, look for an op of which the
    # output tensor also is in the transitive closure.
    # Do not assume a specific op, e.g., ""gradients/e_grad/Reshape_1",
    # because it may vary between builds.
    closure = stepper.sorted_transitive_closure()
    op_with_output_in_closure = None
    for element_name in closure:
      if element_name + ":0" in closure:
        op_with_output_in_closure = str(element_name)
        break

    self.assertIsNotNone(op_with_output_in_closure)
    output_tensor = op_with_output_in_closure + ":0"

    # The op "gradients/?_grad/Reshape_1" is in the transitive closure of the
    # stepper, because it is the control input to another o. However, its
    # output tensor "gradients/?_grad/Reshape_1:0" is also in the transitive
    # closure, because it is the (non-control) input of certain ops. Calling
    # cont() on the op should lead to the caching of the tensor handle for
    # the output tensor.
    stepper.cont(op_with_output_in_closure)

    self.assertEqual([output_tensor], stepper.handle_names())

    # Do a cont() call that uses the cached tensor of
    # "gradients/?_grad/Reshape_1:0".
    stepper.cont(output_tensor)
    self.assertEqual({
        output_tensor: NodeStepper.FEED_TYPE_HANDLE
    }, stepper.last_feed_types())
開發者ID:ComeOnGetMe,項目名稱:tensorflow,代碼行數:37,代碼來源:stepper_test.py

示例3: testAttemptToContToFetchNotInTransitiveClosure

# 需要導入模塊: from tensorflow.python.debug.stepper import NodeStepper [as 別名]
# 或者: from tensorflow.python.debug.stepper.NodeStepper import sorted_transitive_closure [as 別名]
  def testAttemptToContToFetchNotInTransitiveClosure(self):
    stepper = NodeStepper(self.sess, "e:0")

    self.assertEqual(
        ["a:0", "b:0", "b/read:0", "a/read:0", "c:0", "d:0", "e:0"],
        stepper.sorted_transitive_closure())

    with self.assertRaisesRegexp(
        ValueError,
        "Target \"f:0\" is not in the transitive closure for the fetch of the "
        "stepper: \"e:0\""):
      stepper.cont("f:0")
開發者ID:brchiu,項目名稱:tensorflow,代碼行數:14,代碼來源:stepper_test.py


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