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


Python exporter.rewrite_nn_resize_op方法代碼示例

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


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

示例1: test_rewrite_nn_resize_op

# 需要導入模塊: from object_detection import exporter [as 別名]
# 或者: from object_detection.exporter import rewrite_nn_resize_op [as 別名]
def test_rewrite_nn_resize_op(self):
    g = tf.Graph()
    with g.as_default():
      x = array_ops.placeholder(dtypes.float32, shape=(8, 10, 10, 8))
      y = array_ops.placeholder(dtypes.float32, shape=(8, 20, 20, 8))
      s = ops.nearest_neighbor_upsampling(x, 2)
      t = s + y
      exporter.rewrite_nn_resize_op()

    resize_op_found = False
    for op in g.get_operations():
      if op.type == 'ResizeNearestNeighbor':
        resize_op_found = True
        self.assertEqual(op.inputs[0], x)
        self.assertEqual(op.outputs[0].consumers()[0], t.op)
        break

    self.assertTrue(resize_op_found) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:20,代碼來源:exporter_test.py

示例2: test_rewrite_nn_resize_op_odd_size

# 需要導入模塊: from object_detection import exporter [as 別名]
# 或者: from object_detection.exporter import rewrite_nn_resize_op [as 別名]
def test_rewrite_nn_resize_op_odd_size(self):
    g = tf.Graph()
    with g.as_default():
      x = array_ops.placeholder(dtypes.float32, shape=(8, 10, 10, 8))
      s = ops.nearest_neighbor_upsampling(x, 2)
      t = s[:, :19, :19, :]
      exporter.rewrite_nn_resize_op()

    resize_op_found = False
    for op in g.get_operations():
      if op.type == 'ResizeNearestNeighbor':
        resize_op_found = True
        self.assertEqual(op.inputs[0], x)
        self.assertEqual(op.outputs[0].consumers()[0], t.op)
        break

    self.assertTrue(resize_op_found) 
開發者ID:tensorflow,項目名稱:models,代碼行數:19,代碼來源:exporter_tf1_test.py

示例3: test_rewrite_nn_resize_op_quantized_odd_size

# 需要導入模塊: from object_detection import exporter [as 別名]
# 或者: from object_detection.exporter import rewrite_nn_resize_op [as 別名]
def test_rewrite_nn_resize_op_quantized_odd_size(self):
    g = tf.Graph()
    with g.as_default():
      x = array_ops.placeholder(dtypes.float32, shape=(8, 10, 10, 8))
      x_conv = slim.conv2d(x, 8, 1)
      s = ops.nearest_neighbor_upsampling(x_conv, 2)
      t = s[:, :19, :19, :]

      graph_rewriter_config = graph_rewriter_pb2.GraphRewriter()
      graph_rewriter_config.quantization.delay = 500000
      graph_rewriter_fn = graph_rewriter_builder.build(
          graph_rewriter_config, is_training=False)
      graph_rewriter_fn()

      exporter.rewrite_nn_resize_op(is_quantized=True)

    resize_op_found = False
    for op in g.get_operations():
      if op.type == 'ResizeNearestNeighbor':
        resize_op_found = True
        self.assertEqual(op.inputs[0].op.type, 'FakeQuantWithMinMaxVars')
        self.assertEqual(op.outputs[0].consumers()[0], t.op)
        break

    self.assertTrue(resize_op_found) 
開發者ID:tensorflow,項目名稱:models,代碼行數:27,代碼來源:exporter_tf1_test.py

示例4: test_rewrite_nn_resize_op_quantized

# 需要導入模塊: from object_detection import exporter [as 別名]
# 或者: from object_detection.exporter import rewrite_nn_resize_op [as 別名]
def test_rewrite_nn_resize_op_quantized(self):
    g = tf.Graph()
    with g.as_default():
      x = array_ops.placeholder(dtypes.float32, shape=(8, 10, 10, 8))
      x_conv = tf.contrib.slim.conv2d(x, 8, 1)
      y = array_ops.placeholder(dtypes.float32, shape=(8, 20, 20, 8))
      s = ops.nearest_neighbor_upsampling(x_conv, 2)
      t = s + y

      graph_rewriter_config = graph_rewriter_pb2.GraphRewriter()
      graph_rewriter_config.quantization.delay = 500000
      graph_rewriter_fn = graph_rewriter_builder.build(
          graph_rewriter_config, is_training=False)
      graph_rewriter_fn()

      exporter.rewrite_nn_resize_op(is_quantized=True)

    resize_op_found = False
    for op in g.get_operations():
      if op.type == 'ResizeNearestNeighbor':
        resize_op_found = True
        self.assertEqual(op.inputs[0].op.type, 'FakeQuantWithMinMaxVars')
        self.assertEqual(op.outputs[0].consumers()[0], t.op)
        break

    self.assertTrue(resize_op_found) 
開發者ID:ahmetozlu,項目名稱:vehicle_counting_tensorflow,代碼行數:28,代碼來源:exporter_test.py

示例5: test_rewrite_nn_resize_op_quantized

# 需要導入模塊: from object_detection import exporter [as 別名]
# 或者: from object_detection.exporter import rewrite_nn_resize_op [as 別名]
def test_rewrite_nn_resize_op_quantized(self):
    g = tf.Graph()
    with g.as_default():
      x = array_ops.placeholder(dtypes.float32, shape=(8, 10, 10, 8))
      x_conv = slim.conv2d(x, 8, 1)
      y = array_ops.placeholder(dtypes.float32, shape=(8, 20, 20, 8))
      s = ops.nearest_neighbor_upsampling(x_conv, 2)
      t = s + y

      graph_rewriter_config = graph_rewriter_pb2.GraphRewriter()
      graph_rewriter_config.quantization.delay = 500000
      graph_rewriter_fn = graph_rewriter_builder.build(
          graph_rewriter_config, is_training=False)
      graph_rewriter_fn()

      exporter.rewrite_nn_resize_op(is_quantized=True)

    resize_op_found = False
    for op in g.get_operations():
      if op.type == 'ResizeNearestNeighbor':
        resize_op_found = True
        self.assertEqual(op.inputs[0].op.type, 'FakeQuantWithMinMaxVars')
        self.assertEqual(op.outputs[0].consumers()[0], t.op)
        break

    self.assertTrue(resize_op_found) 
開發者ID:tensorflow,項目名稱:models,代碼行數:28,代碼來源:exporter_tf1_test.py

示例6: test_rewrite_nn_resize_op_multiple_path

# 需要導入模塊: from object_detection import exporter [as 別名]
# 或者: from object_detection.exporter import rewrite_nn_resize_op [as 別名]
def test_rewrite_nn_resize_op_multiple_path(self):
    g = tf.Graph()
    with g.as_default():
      with tf.name_scope('nearest_upsampling'):
        x = array_ops.placeholder(dtypes.float32, shape=(8, 10, 10, 8))
        x_stack = tf.stack([tf.stack([x] * 2, axis=3)] * 2, axis=2)
        x_reshape = tf.reshape(x_stack, [8, 20, 20, 8])

      with tf.name_scope('nearest_upsampling'):
        x_2 = array_ops.placeholder(dtypes.float32, shape=(8, 10, 10, 8))
        x_stack_2 = tf.stack([tf.stack([x_2] * 2, axis=3)] * 2, axis=2)
        x_reshape_2 = tf.reshape(x_stack_2, [8, 20, 20, 8])

      t = x_reshape + x_reshape_2

      exporter.rewrite_nn_resize_op()

    graph_def = g.as_graph_def()
    graph_def = strip_unused_lib.strip_unused(
        graph_def,
        input_node_names=[
            'nearest_upsampling/Placeholder', 'nearest_upsampling_1/Placeholder'
        ],
        output_node_names=['add'],
        placeholder_type_enum=dtypes.float32.as_datatype_enum)

    counter_resize_op = 0
    t_input_ops = [op.name for op in t.op.inputs]
    for node in graph_def.node:
      # Make sure Stacks are replaced.
      self.assertNotEqual(node.op, 'Pack')
      if node.op == 'ResizeNearestNeighbor':
        counter_resize_op += 1
        self.assertIn(six.ensure_str(node.name) + ':0', t_input_ops)
    self.assertEqual(counter_resize_op, 2) 
開發者ID:tensorflow,項目名稱:models,代碼行數:37,代碼來源:exporter_tf1_test.py


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