本文整理汇总了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))
示例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))
示例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)
示例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