dbg_metric.py 文件源码

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

项目:LTR-DNN 作者: kn45 项目源码 文件源码
def accumulate_accuracy(self, sess, l, p):
        """update accuracy by inputs and staged value.
        @return: newly-updated accuracy.
        """
        input_dict = {
            self.labels: l,
            self.preds: p}
        ct = sess.run(self.update_acc, feed_dict=input_dict)
        ac = sess.run(self.acc)
        print [(i.name, i.eval(sess)) for i in tf.local_variables()]
        return ac, ct

    def pairwise_accuracy(self, sess, fiter, inp_fn):
        """evaluate the correct pairwise order ratio.
        @return: correct_pair/ total_pair
        @fiter:  an iterable to fetch instance (qry&pos&neg of each query)
        @inp_fn: a func extracting ([qry], [pos], [neg]) from instance
        """
        accuracy = None
        for inst in fiter:
            qrys, poss, negs = inp_fn(inst)
            for qry, pos, neg in itertools.product(qrys, poss, negs):
                accuracy, ct = self.accumulate_accuracy(sess, qry, pos, neg)
        return accuracy, ct
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号