From 3b57c10b5ad6450463d356b39682d5c47fdf696a Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Thu, 10 May 2018 22:57:27 +0200 Subject: [PATCH] Saves calling tf.reduce_mean on all values once. --- network.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/network.py b/network.py index 10d238f..070f0b3 100644 --- a/network.py +++ b/network.py @@ -321,12 +321,13 @@ class Network: print(time.time() - start) start = time.time() + # Running data through networks all_scores = [self.model.predict_on_batch(board) for board in list_of_moves] - transformed_scores = [x if player == 1 else (1-x) for x in all_scores] - scores_means = [tf.reduce_mean(score) for score in all_scores] - transformed_means = [tf.reduce_mean(score) for score in transformed_scores] + + transformed_means = [x if player == 1 else (1-x) for x in scores_means] + print(time.time() - start) return ([scores_means, transformed_means])