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


Python losses.WeightedSmoothL1LocalizationLoss方法代码示例

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


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

示例1: testReturnsCorrectLoss

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def testReturnsCorrectLoss(self):
    batch_size = 2
    num_anchors = 3
    code_size = 4
    prediction_tensor = tf.constant([[[2.5, 0, .4, 0],
                                      [0, 0, 0, 0],
                                      [0, 2.5, 0, .4]],
                                     [[3.5, 0, 0, 0],
                                      [0, .4, 0, .9],
                                      [0, 0, 1.5, 0]]], tf.float32)
    target_tensor = tf.zeros([batch_size, num_anchors, code_size])
    weights = tf.constant([[2, 1, 1],
                           [0, 3, 0]], tf.float32)
    loss_op = losses.WeightedSmoothL1LocalizationLoss()
    loss = loss_op(prediction_tensor, target_tensor, weights=weights)

    exp_loss = 7.695
    with self.test_session() as sess:
      loss_output = sess.run(loss)
      self.assertAllClose(loss_output, exp_loss) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:22,代码来源:losses_test.py

示例2: test_build_weighted_smooth_l1_localization_loss

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_build_weighted_smooth_l1_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:losses_builder_test.py

示例3: testReturnsCorrectLoss

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def testReturnsCorrectLoss(self):
    batch_size = 2
    num_anchors = 3
    code_size = 4
    prediction_tensor = tf.constant([[[2.5, 0, .4, 0],
                                      [0, 0, 0, 0],
                                      [0, 2.5, 0, .4]],
                                     [[3.5, 0, 0, 0],
                                      [0, .4, 0, .9],
                                      [0, 0, 1.5, 0]]], tf.float32)
    target_tensor = tf.zeros([batch_size, num_anchors, code_size])
    weights = tf.constant([[2, 1, 1],
                           [0, 3, 0]], tf.float32)
    loss_op = losses.WeightedSmoothL1LocalizationLoss()
    loss = loss_op(prediction_tensor, target_tensor, weights=weights)
    loss = tf.reduce_sum(loss)

    exp_loss = 7.695
    with self.test_session() as sess:
      loss_output = sess.run(loss)
      self.assertAllClose(loss_output, exp_loss) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:losses_test.py

示例4: test_build_weighted_smooth_l1_localization_loss_default_delta

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_build_weighted_smooth_l1_localization_loss_default_delta(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    self.assertAlmostEqual(localization_loss._delta, 1.0) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:19,代码来源:losses_builder_test.py

示例5: test_anchorwise_output

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_anchorwise_output(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    predictions = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    targets = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    weights = tf.constant([[1.0, 1.0]])
    loss = localization_loss(predictions, targets, weights=weights)
    self.assertEqual(loss.shape, [1, 2]) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:23,代码来源:losses_builder_test.py

示例6: test_build_weighted_smooth_l1_localization_loss_default_delta

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_build_weighted_smooth_l1_localization_loss_default_delta(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    self.assertAlmostEqual(localization_loss._delta, 1.0) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:19,代码来源:losses_builder_test.py

示例7: test_anchorwise_output

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_anchorwise_output(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    predictions = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    targets = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    weights = tf.constant([[1.0, 1.0]])
    loss = localization_loss(predictions, targets, weights=weights)
    self.assertEqual(loss.shape, [1, 2]) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:23,代码来源:losses_builder_test.py

示例8: test_build_weighted_smooth_l1_localization_loss_non_default_delta

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_build_weighted_smooth_l1_localization_loss_non_default_delta(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
          delta: 0.1
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    self.assertAlmostEqual(localization_loss._delta, 0.1) 
开发者ID:ambakick,项目名称:Person-Detection-and-Tracking,代码行数:20,代码来源:losses_builder_test.py

示例9: test_anchorwise_output

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_anchorwise_output(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
          anchorwise_output: true
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    predictions = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    targets = tf.constant([[[0.0, 0.0, 1.0, 1.0], [0.0, 0.0, 1.0, 1.0]]])
    weights = tf.constant([[1.0, 1.0]])
    loss = localization_loss(predictions, targets, weights=weights)
    self.assertEqual(loss.shape, [1, 2]) 
开发者ID:PacktPublishing,项目名称:Hands-On-Machine-Learning-with-OpenCV-4,代码行数:24,代码来源:losses_builder_test.py

示例10: test_build_weighted_smooth_l1_localization_loss_non_default_delta

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedSmoothL1LocalizationLoss [as 别名]
def test_build_weighted_smooth_l1_localization_loss_non_default_delta(self):
    losses_text_proto = """
      localization_loss {
        weighted_smooth_l1 {
          delta: 0.1
        }
      }
      classification_loss {
        weighted_softmax {
        }
      }
    """
    losses_proto = losses_pb2.Loss()
    text_format.Merge(losses_text_proto, losses_proto)
    _, localization_loss, _, _, _ = losses_builder.build(losses_proto)
    self.assertTrue(isinstance(localization_loss,
                               losses.WeightedSmoothL1LocalizationLoss))
    self.assertAlmostEqual(localization_loss._delta, 0.1) 
开发者ID:itsamitgoel,项目名称:Gun-Detector,代码行数:20,代码来源:losses_builder_test.py


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