builder.py 文件源码

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

项目:KBOPrediction 作者: riceluxs1t 项目源码 文件源码
def get_accuracy(self, x_test_home, x_test_away, y_test, keep_prop=1.0):
        """
        The predictions from x_test_home and x_test_away are mapped to 1 or 0 depending on whether the
        home team wins or not. Then it is compared with y_test which is the ground truth.
        """
        predict = tf.map_fn(
            lambda x: x[0] > x[1],
            self.sess.run(
                self.hypothesis, 
                feed_dict={
                self.X_home: x_test_home, 
                self.X_away: x_test_away, 
                self.Y: y_test, 
                self.keep_prob: keep_prop}
            ), 
            dtype=bool)

        real = tf.map_fn(
            lambda x: x[0] > x[1],
            y_test,
            dtype=bool)

        return self.sess.run(
            tf.divide(
                tf.reduce_sum(tf.cast(tf.equal(predict, real), dtype=tf.int32)), len(y_test)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号