當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。