From 55898d0e66db9e902acb336d5816e343a7d2f94d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoffer=20M=C3=BCller=20Madsen?= Date: Mon, 12 Mar 2018 00:11:55 +0100 Subject: [PATCH] renaming parameters --- README.org | 6 +++--- main.py | 14 ++++++++++---- network.py | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.org b/README.org index 61549cc..2fed69a 100644 --- a/README.org +++ b/README.org @@ -56,7 +56,7 @@ The following examples describe commmon operations. *** Evaluate model named =quack= using default evaluation method (currently =random=) -=python3 --eval --model-name=quack= +=python3 --eval --model=quack= *** Evaluate default model using evaluation methods =random= and =pubeval= @@ -73,14 +73,14 @@ directory. Otherwise, the model is stored in =models/$MODEL=. Along with the Tensorflow checkpoint files in the directory, the following files are stored: -- =model.episodes=: The number of episodes of training performed with the +- =episodes_trained=: The number of episodes of training performed with the model - =logs/eval.log=: Log of all completed evaluations performed on the model. The format of this file is specified in [[Log format]]. - =logs/train.log=: Log of all completed training sessions performed on the model. If a training session is aborted before the pre-specified episode target is reached, nothing will be written to this file, although - =model.episodes= will be updated every time the model is saved to disk. The + =episodes_trained= will be updated every time the model is saved to disk. The format of this file is specified in [[Log format]]. ** Log format diff --git a/main.py b/main.py index 0bfcea3..2012b0c 100644 --- a/main.py +++ b/main.py @@ -3,6 +3,12 @@ import sys import os import time +models_storage_path = 'models' + +# Create models folder +if not os.path.exists(models_storage_path): + os.makedirs(models_storage_path) + # Define helper functions def log_train_outcome(outcome, trained_eps = 0): format_vars = { 'trained_eps': trained_eps, @@ -34,9 +40,9 @@ parser = argparse.ArgumentParser(description="Backgammon games") parser.add_argument('--episodes', action='store', dest='episode_count', type=int, default=1000, help='number of episodes to train') -parser.add_argument('--model-path', action='store', dest='model_path', - default='./model', - help='path to Tensorflow model') +parser.add_argument('--model', action='store', dest='model', + default='default', + help='name of Tensorflow model to use') parser.add_argument('--eval-methods', action='store', default=['random'], nargs='*', help='specifies evaluation methods') @@ -55,7 +61,7 @@ parser.add_argument('--start-episode', action='store', dest='start_episode', args = parser.parse_args() config = { - 'model_path': args.model_path, + 'model_path': os.path.join(models_storage_path, args.model), 'episode_count': args.episode_count, 'eval_methods': args.eval_methods, 'train': args.train, diff --git a/network.py b/network.py index 435ccde..21da4a7 100644 --- a/network.py +++ b/network.py @@ -26,7 +26,7 @@ class Network: # Restore trained episode count for model - episode_count_path = os.path.join(self.checkpoint_path, "model.episodes") + episode_count_path = os.path.join(self.checkpoint_path, "episodes_trained") if os.path.isfile(episode_count_path): with open(episode_count_path, 'r') as f: self.config['start_episode'] = int(f.read()) @@ -91,7 +91,7 @@ class Network: def save_model(self, episode_count): self.saver.save(self.session, os.path.join(self.checkpoint_path, 'model.ckpt')) - with open(os.path.join(self.checkpoint_path, "model.episodes"), 'w+') as f: + with open(os.path.join(self.checkpoint_path, "episodes_trained"), 'w+') as f: f.write(str(episode_count) + "\n") def restore_model(self):