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


Python tensorflow.truediv方法代碼示例

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


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

示例1: iou

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import truediv [as 別名]
def iou(boxlist1, boxlist2, scope=None):
  """Computes pairwise intersection-over-union between box collections.

  Args:
    boxlist1: BoxList holding N boxes
    boxlist2: BoxList holding M boxes
    scope: name scope.

  Returns:
    a tensor with shape [N, M] representing pairwise iou scores.
  """
  with tf.name_scope(scope, 'IOU'):
    intersections = intersection(boxlist1, boxlist2)
    areas1 = area(boxlist1)
    areas2 = area(boxlist2)
    unions = (
        tf.expand_dims(areas1, 1) + tf.expand_dims(areas2, 0) - intersections)
    return tf.where(
        tf.equal(intersections, 0.0),
        tf.zeros_like(intersections), tf.truediv(intersections, unions)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:22,代碼來源:box_list_ops.py

示例2: matched_iou

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import truediv [as 別名]
def matched_iou(boxlist1, boxlist2, scope=None):
  """Compute intersection-over-union between corresponding boxes in boxlists.

  Args:
    boxlist1: BoxList holding N boxes
    boxlist2: BoxList holding N boxes
    scope: name scope.

  Returns:
    a tensor with shape [N] representing pairwise iou scores.
  """
  with tf.name_scope(scope, 'MatchedIOU'):
    intersections = matched_intersection(boxlist1, boxlist2)
    areas1 = area(boxlist1)
    areas2 = area(boxlist2)
    unions = areas1 + areas2 - intersections
    return tf.where(
        tf.equal(intersections, 0.0),
        tf.zeros_like(intersections), tf.truediv(intersections, unions)) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:21,代碼來源:box_list_ops.py

示例3: ioa

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import truediv [as 別名]
def ioa(boxlist1, boxlist2, scope=None):
  """Computes pairwise intersection-over-area between box collections.

  intersection-over-area (IOA) between two boxes box1 and box2 is defined as
  their intersection area over box2's area. Note that ioa is not symmetric,
  that is, ioa(box1, box2) != ioa(box2, box1).

  Args:
    boxlist1: BoxList holding N boxes
    boxlist2: BoxList holding M boxes
    scope: name scope.

  Returns:
    a tensor with shape [N, M] representing pairwise ioa scores.
  """
  with tf.name_scope(scope, 'IOA'):
    intersections = intersection(boxlist1, boxlist2)
    areas = tf.expand_dims(area(boxlist2), 0)
    return tf.truediv(intersections, areas) 
開發者ID:ringringyi,項目名稱:DOTA_models,代碼行數:21,代碼來源:box_list_ops.py

示例4: log_likelihood

# 需要導入模塊: import tensorflow [as 別名]
# 或者: from tensorflow import truediv [as 別名]
def log_likelihood(mu, var, x, muq, varq, a, mask_flat, config):
    if config.out_distr == 'bernoulli':
        log_lik = log_bernoulli(x, mu, eps=1e-6)  # (bs*L, d1*d2)
    elif config.out_distr == 'gaussian':
        log_lik = log_gaussian(x, mu, var)

    log_lik = tf.reduce_sum(log_lik, 1)  # (bs*L, )
    log_lik = tf.multiply(mask_flat, log_lik)
    # TODO: dropout scales the output as input/keep_prob. Issue?
    if config.ll_keep_prob < 1.0:
        log_lik = tf.layers.dropout(log_lik, config.ll_keep_prob)

    # We compute the log-likelihood *per frame*
    num_el = tf.reduce_sum(mask_flat)
    log_px_given_a = tf.truediv(tf.reduce_sum(log_lik), num_el)  # ()

    if config.use_vae:
        log_qa_given_x = tf.reduce_sum(log_gaussian(a, muq, varq), 1)  # (bs*L, )
        log_qa_given_x = tf.multiply(mask_flat, log_qa_given_x)
        log_qa_given_x = tf.truediv(tf.reduce_sum(log_qa_given_x), num_el)  # ()
    else:
        log_qa_given_x = tf.constant(0.0, dtype=tf.float32, shape=())

    LL = log_px_given_a - log_qa_given_x
    return LL, log_px_given_a, log_qa_given_x 
開發者ID:simonkamronn,項目名稱:kvae,代碼行數:27,代碼來源:nn.py


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