metrics.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:odin 作者: imito 项目源码 文件源码
def to_llr(x, name="LogLikelihoodRatio"):
  ''' Convert a matrix of probabilities into log-likelihood ratio
  :math:`LLR = log(\\frac{prob(data|target)}{prob(data|non-target)})`
  '''
  if not is_tensor(x):
    x /= np.sum(x, axis=-1, keepdims=True)
    x = np.clip(x, 10e-8, 1. - 10e-8)
    return np.log(x / (np.cast(1., x.dtype) - x))
  else:
    with tf.variable_scope(name):
      x /= tf.reduce_sum(x, axis=-1, keepdims=True)
      x = tf.clip_by_value(x, 10e-8, 1. - 10e-8)
      return tf.log(x / (tf.cast(1., x.dtype.base_dtype) - x))


# ===========================================================================
# Speech task metrics
# ===========================================================================
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号