Commit f613c663 authored by Avisek Naug's avatar Avisek Naug 🎨
Browse files

fix tf init opt errors: initialize agent and lstm in main thread

parent 46cb51da
......@@ -419,7 +419,7 @@ if __name__ == '__main__':
log.setLevel(args.logging)
# setting up environment and agent
env = Env()
env = Env(load_model('weights.best.hdf5'))
agent = get_agent(env)
log.info('Initializing agent.')
agent.load_weights(args.use_control)
......@@ -429,6 +429,11 @@ if __name__ == '__main__':
agent.test(env, nb_episodes=1, verbose=0, visualize=False,
nb_max_episode_steps=10)
log.info('MAIN THREAD: Creating empty LSTM model of energy consumption.')
lstm = createmodel()
log.info('MAIN THREAD: Initialize relearning agent with same environment')
re_agent = get_agent(env)
# setting up multi-threading structures for control/learning
signal_stop, signal_reload = Event(), Event()
lock_policy = Lock()
......@@ -474,7 +479,8 @@ if __name__ == '__main__':
learn_control(source=args.store_at, save_to=args.use_control,
relearn_window=args.relearn_window,
duration=args.training_duration, signal_stop=signal_stop,
signal_reload=signal_reload, lock_policy=lock_policy)
signal_reload=signal_reload, lock_policy=lock_policy,
lstm=lstm, re_agent=re_agent)
end = time.perf_counter()
except KeyboardInterrupt:
signal_stop.set()
......
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