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


Python losses.WeightedL2LocalizationLoss方法代码示例

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


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

示例1: testReturnsCorrectLoss

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

    expected_loss = (3 * 5 * 4) / 2.0
    with self.test_session() as sess:
      loss_output = sess.run(loss)
      self.assertAllClose(loss_output, expected_loss) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:losses_test.py

示例2: testReturnsCorrectNanLoss

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedL2LocalizationLoss [as 别名]
def testReturnsCorrectNanLoss(self):
    batch_size = 3
    num_anchors = 10
    code_size = 4
    prediction_tensor = tf.ones([batch_size, num_anchors, code_size])
    target_tensor = tf.concat([
        tf.zeros([batch_size, num_anchors, code_size / 2]),
        tf.ones([batch_size, num_anchors, code_size / 2]) * np.nan
    ], axis=2)
    weights = tf.ones([batch_size, num_anchors])
    loss_op = losses.WeightedL2LocalizationLoss()
    loss = loss_op(prediction_tensor, target_tensor, weights=weights,
                   ignore_nan_targets=True)

    expected_loss = (3 * 5 * 4) / 2.0
    with self.test_session() as sess:
      loss_output = sess.run(loss)
      self.assertAllClose(loss_output, expected_loss) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:20,代码来源:losses_test.py

示例3: testReturnsCorrectWeightedLoss

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

    expected_loss = (3 * 5 * 4) / 2.0
    with self.test_session() as sess:
      loss_output = sess.run(loss)
      self.assertAllClose(loss_output, expected_loss) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:19,代码来源:losses_test.py

示例4: testReturnsCorrectNanLoss

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedL2LocalizationLoss [as 别名]
def testReturnsCorrectNanLoss(self):
    batch_size = 3
    num_anchors = 10
    code_size = 4
    prediction_tensor = tf.ones([batch_size, num_anchors, code_size])
    target_tensor = tf.concat([
        tf.zeros([batch_size, num_anchors, code_size / 2]),
        tf.ones([batch_size, num_anchors, code_size / 2]) * np.nan
    ], axis=2)
    weights = tf.ones([batch_size, num_anchors])
    loss_op = losses.WeightedL2LocalizationLoss()
    loss = loss_op(prediction_tensor, target_tensor, weights=weights,
                   ignore_nan_targets=True)
    loss = tf.reduce_sum(loss)

    expected_loss = (3 * 5 * 4) / 2.0
    with self.test_session() as sess:
      loss_output = sess.run(loss)
      self.assertAllClose(loss_output, expected_loss) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:21,代码来源:losses_test.py

示例5: testReturnsCorrectWeightedLossWithLossesMask

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedL2LocalizationLoss [as 别名]
def testReturnsCorrectWeightedLossWithLossesMask(self):
    batch_size = 4
    num_anchors = 10
    code_size = 4
    prediction_tensor = tf.ones([batch_size, num_anchors, code_size])
    target_tensor = tf.zeros([batch_size, num_anchors, code_size])
    weights = tf.constant([[1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
                           [1, 1, 1, 1, 1, 1, 1, 1, 0, 0],
                           [1, 1, 1, 1, 1, 0, 0, 0, 0, 0],
                           [1, 1, 1, 1, 1, 0, 0, 0, 0, 0]], tf.float32)
    losses_mask = tf.constant([True, False, True, True], tf.bool)
    loss_op = losses.WeightedL2LocalizationLoss()
    loss = tf.reduce_sum(loss_op(prediction_tensor, target_tensor,
                                 weights=weights, losses_mask=losses_mask))

    expected_loss = (3 * 5 * 4) / 2.0
    with self.test_session() as sess:
      loss_output = sess.run(loss)
      self.assertAllClose(loss_output, expected_loss) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:21,代码来源:losses_test.py

示例6: test_build_weighted_l2_localization_loss

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedL2LocalizationLoss [as 别名]
def test_build_weighted_l2_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_l2 {
        }
      }
      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.WeightedL2LocalizationLoss)) 
开发者ID:cagbal,项目名称:ros_people_object_detection_tensorflow,代码行数:18,代码来源:losses_builder_test.py

示例7: test_build_weighted_l2_localization_loss

# 需要导入模块: from object_detection.core import losses [as 别名]
# 或者: from object_detection.core.losses import WeightedL2LocalizationLoss [as 别名]
def test_build_weighted_l2_localization_loss(self):
    losses_text_proto = """
      localization_loss {
        weighted_l2 {
        }
      }
      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.WeightedL2LocalizationLoss)) 
开发者ID:ambakick,项目名称:Person-Detection-and-Tracking,代码行数:18,代码来源:losses_builder_test.py


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