Commit 3221e984 authored by hazrmard's avatar hazrmard
Browse files

some new logging printouts during re-learning

parent fe0941a9
...@@ -326,7 +326,7 @@ def learn_control(source: str, save_to: str, relearn_window: int, duration: int, ...@@ -326,7 +326,7 @@ def learn_control(source: str, save_to: str, relearn_window: int, duration: int,
relearndf.to_pickle('relearn.pkl') relearndf.to_pickle('relearn.pkl')
# Train it with the newly initialized environment # Train it with the newly initialized environment
log.info('Adapting control policy') log.info('Adapting control policy.')
with lock_policy: with lock_policy:
if signal_stop.is_set(): if signal_stop.is_set():
log.info('Stopping re-learning.') log.info('Stopping re-learning.')
...@@ -334,7 +334,9 @@ def learn_control(source: str, save_to: str, relearn_window: int, duration: int, ...@@ -334,7 +334,9 @@ def learn_control(source: str, save_to: str, relearn_window: int, duration: int,
# retrain on the same model # retrain on the same model
lstm = load_model('weights.best.hdf5') lstm = load_model('weights.best.hdf5')
log.info('Re-training LSTM model of energy consumption.')
retrain(lstm, relearndf, epochs=25) retrain(lstm, relearndf, epochs=25)
log.info('LSTM energy model training finished.')
# create new model of environment # create new model of environment
env = Env(datapath='relearn.pkl', modelpath = 'weights.best.hdf5') env = Env(datapath='relearn.pkl', modelpath = 'weights.best.hdf5')
...@@ -343,7 +345,9 @@ def learn_control(source: str, save_to: str, relearn_window: int, duration: int, ...@@ -343,7 +345,9 @@ def learn_control(source: str, save_to: str, relearn_window: int, duration: int,
# Do not reinitialize the agent, instead use a COPY of the existing agent file # Do not reinitialize the agent, instead use a COPY of the existing agent file
agent = get_agent(env) agent = get_agent(env)
agent.load_weights('agent_weights.h5f') agent.load_weights('agent_weights.h5f')
log.info('Training new control agent.')
train_agent(agent=agent, env=env, steps=duration, dest=save_to) train_agent(agent=agent, env=env, steps=duration, dest=save_to)
log.info('Control policy adapted.')
signal_reload.set() signal_reload.set()
except Exception as e: except Exception as e:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment