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


Python ops.padded_one_hot_encoding方法代码示例

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


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

示例1: _get_inputs

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def _get_inputs(input_queue, num_classes):
  """Dequeue batch and construct inputs to object detection model.

  Args:
    input_queue: BatchQueue object holding enqueued tensor_dicts.
    num_classes: Number of classes.

  Returns:
    images: a list of 3-D float tensor of images.
    locations_list: a list of tensors of shape [num_boxes, 4]
      containing the corners of the groundtruth boxes.
    classes_list: a list of padded one-hot tensors containing target classes.
    masks_list: a list of 3-D float tensors of shape [num_boxes, image_height,
      image_width] containing instance masks for objects if present in the
      input_queue. Else returns None.
  """
  read_data_list = input_queue.dequeue()
  label_id_offset = 1
  def extract_images_and_targets(read_data):
    image = read_data[fields.InputDataFields.image]
    location_gt = read_data[fields.InputDataFields.groundtruth_boxes]
    classes_gt = tf.cast(read_data[fields.InputDataFields.groundtruth_classes],
                         tf.int32)
    classes_gt -= label_id_offset
    classes_gt = util_ops.padded_one_hot_encoding(indices=classes_gt,
                                                  depth=num_classes, left_pad=0)
    masks_gt = read_data.get(fields.InputDataFields.groundtruth_instance_masks)
    return image, location_gt, classes_gt, masks_gt
  return zip(*map(extract_images_and_targets, read_data_list)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:31,代码来源:trainer.py

示例2: test_correct_one_hot_tensor_with_no_pad

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_correct_one_hot_tensor_with_no_pad(self):
    indices = tf.constant([1, 2, 3, 5])
    one_hot_tensor = ops.padded_one_hot_encoding(indices, depth=6, left_pad=0)
    expected_tensor = np.array([[0, 1, 0, 0, 0, 0],
                                [0, 0, 1, 0, 0, 0],
                                [0, 0, 0, 1, 0, 0],
                                [0, 0, 0, 0, 0, 1]], np.float32)
    with self.test_session() as sess:
      out_one_hot_tensor = sess.run(one_hot_tensor)
      self.assertAllClose(out_one_hot_tensor, expected_tensor, rtol=1e-10,
                          atol=1e-10) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:13,代码来源:ops_test.py

示例3: test_correct_one_hot_tensor_with_pad_one

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_correct_one_hot_tensor_with_pad_one(self):
    indices = tf.constant([1, 2, 3, 5])
    one_hot_tensor = ops.padded_one_hot_encoding(indices, depth=6, left_pad=1)
    expected_tensor = np.array([[0, 0, 1, 0, 0, 0, 0],
                                [0, 0, 0, 1, 0, 0, 0],
                                [0, 0, 0, 0, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 1]], np.float32)
    with self.test_session() as sess:
      out_one_hot_tensor = sess.run(one_hot_tensor)
      self.assertAllClose(out_one_hot_tensor, expected_tensor, rtol=1e-10,
                          atol=1e-10) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:13,代码来源:ops_test.py

示例4: test_correct_one_hot_tensor_with_pad_three

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_correct_one_hot_tensor_with_pad_three(self):
    indices = tf.constant([1, 2, 3, 5])
    one_hot_tensor = ops.padded_one_hot_encoding(indices, depth=6, left_pad=3)
    expected_tensor = np.array([[0, 0, 0, 0, 1, 0, 0, 0, 0],
                                [0, 0, 0, 0, 0, 1, 0, 0, 0],
                                [0, 0, 0, 0, 0, 0, 1, 0, 0],
                                [0, 0, 0, 0, 0, 0, 0, 0, 1]], np.float32)
    with self.test_session() as sess:
      out_one_hot_tensor = sess.run(one_hot_tensor)
      self.assertAllClose(out_one_hot_tensor, expected_tensor, rtol=1e-10,
                          atol=1e-10) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:13,代码来源:ops_test.py

示例5: test_correct_padded_one_hot_tensor_with_empty_indices

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_correct_padded_one_hot_tensor_with_empty_indices(self):
    depth = 6
    pad = 2
    indices = tf.constant([])
    one_hot_tensor = ops.padded_one_hot_encoding(
        indices, depth=depth, left_pad=pad)
    expected_tensor = np.zeros((0, depth + pad))
    with self.test_session() as sess:
      out_one_hot_tensor = sess.run(one_hot_tensor)
      self.assertAllClose(out_one_hot_tensor, expected_tensor, rtol=1e-10,
                          atol=1e-10) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:13,代码来源:ops_test.py

示例6: test_raise_value_error_on_rank_two_input

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_raise_value_error_on_rank_two_input(self):
    indices = tf.constant(1.0, shape=(2, 3))
    with self.assertRaises(ValueError):
      ops.padded_one_hot_encoding(indices, depth=6, left_pad=2) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:6,代码来源:ops_test.py

示例7: test_raise_value_error_on_negative_pad

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_raise_value_error_on_negative_pad(self):
    indices = tf.constant(1.0, shape=(2, 3))
    with self.assertRaises(ValueError):
      ops.padded_one_hot_encoding(indices, depth=6, left_pad=-1) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:6,代码来源:ops_test.py

示例8: test_raise_value_error_on_float_pad

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_raise_value_error_on_float_pad(self):
    indices = tf.constant(1.0, shape=(2, 3))
    with self.assertRaises(ValueError):
      ops.padded_one_hot_encoding(indices, depth=6, left_pad=0.1) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:6,代码来源:ops_test.py

示例9: test_raise_value_error_on_float_depth

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_raise_value_error_on_float_depth(self):
    indices = tf.constant(1.0, shape=(2, 3))
    with self.assertRaises(ValueError):
      ops.padded_one_hot_encoding(indices, depth=0.1, left_pad=2) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:6,代码来源:ops_test.py

示例10: test_return_none_on_zero_depth

# 需要导入模块: from object_detection.utils import ops [as 别名]
# 或者: from object_detection.utils.ops import padded_one_hot_encoding [as 别名]
def test_return_none_on_zero_depth(self):
    indices = tf.constant([1, 2, 3, 4, 5])
    one_hot_tensor = ops.padded_one_hot_encoding(indices, depth=0, left_pad=2)
    self.assertEqual(one_hot_tensor, None) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:6,代码来源:ops_test.py


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