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


Python graph_editor.select_ops方法代碼示例

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


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

示例1: capture_ops

# 需要導入模塊: from tensorflow.contrib import graph_editor [as 別名]
# 或者: from tensorflow.contrib.graph_editor import select_ops [as 別名]
def capture_ops():
    """Decorator to capture ops created in the block.
    with capture_ops() as ops:
      # create some ops
    print(ops) # => prints ops created.
    """

    micros = int(time.time()*10**6)
    scope_name = str(micros)
    op_list = []
    with tf.name_scope(scope_name):
        yield op_list

    g = tf.get_default_graph()
    op_list.extend(ge.select_ops(scope_name+"/.*", graph=g)) 
開發者ID:openai,項目名稱:glow,代碼行數:17,代碼來源:memory_saving_gradients.py

示例2: capture_ops

# 需要導入模塊: from tensorflow.contrib import graph_editor [as 別名]
# 或者: from tensorflow.contrib.graph_editor import select_ops [as 別名]
def capture_ops():
    """Decorator to capture ops created in the block.
    with capture_ops() as ops:
      # create some ops
    print(ops) # => prints ops created.
    """

    micros = int(time.time() * 10**6)
    scope_name = str(micros)
    op_list = []
    with tf.name_scope(scope_name):
        yield op_list

    g = tf.get_default_graph()
    op_list.extend(ge.select_ops(scope_name + "/.*", graph=g)) 
開發者ID:PRBonn,項目名稱:bonnet,代碼行數:17,代碼來源:msg.py

示例3: test_transform

# 需要導入模塊: from tensorflow.contrib import graph_editor [as 別名]
# 或者: from tensorflow.contrib.graph_editor import select_ops [as 別名]
def test_transform(self):
    transformer = ge.Transformer()
    def my_transform_op_handler(info, op):
      add_noise = op.name.startswith("Add")
      op_ = ge.transform.copy_op_handler(info, op)
      if add_noise:
        # add some noise to op
        with info.graph_.as_default():
          t_ = tf.add(tf.constant(1.0, shape=[10], name="Noise"),
                      op_.outputs[0], name="AddNoise")
        # return the "noisy" op
        return t_.op
      else:
        return op_
    transformer.transform_op_handler = my_transform_op_handler

    graph = tf.Graph()
    transformer(self.graph, graph, "", "")
    matcher0 = ge.matcher("AddNoise").input_ops(
        "Noise", ge.matcher("Add").input_ops("Const", "Input"))
    matcher1 = ge.matcher("AddNoise_1").input_ops(
        "Noise_1", ge.matcher("Add_1").input_ops("Const_1", matcher0))
    matcher2 = ge.matcher("AddNoise_2").input_ops(
        "Noise_2", ge.matcher("Add_2").input_ops("Const_2", matcher1))
    top = ge.select_ops("^AddNoise_2$", graph=graph)[0]
    self.assertTrue(matcher2(top)) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:28,代碼來源:transform_test.py

示例4: test_transform_in_place

# 需要導入模塊: from tensorflow.contrib import graph_editor [as 別名]
# 或者: from tensorflow.contrib.graph_editor import select_ops [as 別名]
def test_transform_in_place(self):
    transformer = ge.Transformer()
    def my_transform_op_handler_in_place(info, op):
      add_noise = op.name.startswith("Add")
      op = ge.transform.transform_op_in_place(info, op,
                                              detach_outputs=add_noise)
      if add_noise:
        # add some noise to op
        with info.graph_.as_default():
          t = tf.add(tf.constant(1.0, shape=[10], name="Noise"), op.outputs[0],
                     name="AddNoise")
        # return the "noisy" op
        return t.op
      else:
        return op
    transformer.transform_op_handler = my_transform_op_handler_in_place

    transformer(self.graph, self.graph, "", "")
    matcher0 = ge.matcher("AddNoise").input_ops(
        "Noise", ge.matcher("Add").input_ops("Const", "Input"))
    matcher1 = ge.matcher("AddNoise_1").input_ops(
        "Noise_1", ge.matcher("Add_1").input_ops("Const_1", matcher0))
    matcher2 = ge.matcher("AddNoise_2").input_ops(
        "Noise_2", ge.matcher("Add_2").input_ops("Const_2", matcher1))
    top = ge.select_ops("^AddNoise_2$", graph=self.graph)[0]
    self.assertTrue(matcher2(top)) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:28,代碼來源:transform_test.py

示例5: capture_ops

# 需要導入模塊: from tensorflow.contrib import graph_editor [as 別名]
# 或者: from tensorflow.contrib.graph_editor import select_ops [as 別名]
def capture_ops():
  """Decorator to capture ops created in the block.
  with capture_ops() as ops:
    # create some ops
  print(ops) # => prints ops created.
  """

  micros = int(time.time()*10**6)
  scope_name = str(micros)
  op_list = []
  with tf.name_scope(scope_name):
    yield op_list

  g = tf.get_default_graph()
  op_list.extend(ge.select_ops(scope_name+"/.*", graph=g)) 
開發者ID:cybertronai,項目名稱:gradient-checkpointing,代碼行數:17,代碼來源:memory_saving_gradients.py


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