From b7708b367528a51ede33f4e8ba8799156f4cef57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Tue, 22 May 2018 15:15:36 +0200 Subject: [PATCH] train-evaluate-save --- bin/train-evaluate-save | 48 ++++++++++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/bin/train-evaluate-save b/bin/train-evaluate-save index 00b6411..70639df 100755 --- a/bin/train-evaluate-save +++ b/bin/train-evaluate-save @@ -1,30 +1,30 @@ #!/usr/bin/env ruby +MODELS_DIR = 'models' + def save(model_name) require 'date' - models_dir = 'models' - model_path = File.join(models_dir, model_name) - if not File.exists? model_path then - return false - end + model_path = File.join(MODELS_DIR, model_name) episode_count = (File.read File.join(model_path, 'episodes_trained')).to_i puts "Found model #{model_name} with episodes #{episode_count} trained!" file_name = "model-#{model_name}-#{episode_count}-#{Time.now.strftime('%Y%m%d-%H%M%S')}.tar.gz" - save_path = File.join(models_dir, 'saves', file_name) + save_path = File.join(MODELS_DIR, 'saves', file_name) puts "Saving to #{save_path}" - system("tar", "-cvzf", save_path, "-C", models_dir, model_name) - - return true + system("tar", "-cvzf", save_path, "-C", MODELS_DIR, model_name) end def train(model, episodes) system("python3", "main.py", "--train", "--model", model, "--episodes", episodes.to_s) end +def force_train(model, episodes) + system("python3", "main.py", "--train", "--force-creation", "--model", model, "--episodes", episodes.to_s) +end + def evaluate(model, episodes, method) system("python3", "main.py", "--eval" , "--model", model, "--episodes", episodes.to_s, "--eval-methods", method) end @@ -33,11 +33,9 @@ model = ARGV[0] if model.nil? then raise "no model specified" end -while true do +if not File.exists? File.join(MODELS_DIR, model) then + force_train model, 10 save model - train model, 1000 - save model - train model, 1000 3.times do evaluate model, 250, "pubeval" end @@ -45,3 +43,27 @@ while true do evaluate model, 250, "dumbeval" end end + +# while true do +# save model +# train model, 1000 +# save model +# train model, 1000 +# 3.times do +# evaluate model, 250, "pubeval" +# end +# 3.times do +# evaluate model, 250, "dumbeval" +# end +# end + +while true do + save model + train model, 500 + 5.times do + evaluate model, 250, "pubeval" + end + 5.times do + evaluate model, 250, "dumbeval" + end +end