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)))
评论列表
文章目录