From b7a0a83c3c8add0a349f463988c866a9ae61d24d Mon Sep 17 00:00:00 2001
From: Armin <armin.co@hs-bochum.de>
Date: Fri, 12 Mar 2021 11:27:24 +0100
Subject: [PATCH] Only show log if there is a "offline" history.

---
 environment_wrapper.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/environment_wrapper.py b/environment_wrapper.py
index 2c8317b..c366b1e 100644
--- a/environment_wrapper.py
+++ b/environment_wrapper.py
@@ -77,7 +77,6 @@ def one_episode(environment, agent, render, learn, conf=None, max_steps=1000):
 def learn_offline(agent, conf):
     """ Train the agent with its memories. """
     print('Learning with ', len(agent.memory.history), ' memories.')
-    agent.epsilon = agent.epsilon_min
 
     score_history = []
     avg_score_history = []
@@ -89,6 +88,7 @@ def learn_offline(agent, conf):
         pbar.set_description(desc)
         pbar.refresh()
         if i % conf.offline_validate_every_x_iteration == 1 and conf.offline_validate_every_x_iteration is not -1:
+            agent.epsilon = agent.epsilon_min
             score = one_episode(conf.env, agent, conf.render, False, conf=conf)
             score_history.append(score)
             is_solved = np.mean(score_history[-25:])
@@ -96,7 +96,8 @@ def learn_offline(agent, conf):
             avg_score_history.append(is_solved)
             if is_solved > IS_SOLVED:
                 break
-    process_logs(avg_score_history, score_history, conf)
+    if conf.offline_validate_every_x_iteration is not -1:
+        process_logs(avg_score_history, score_history, conf)
 
 
 
-- 
GitLab