mirror of
https://github.com/gryf/coach.git
synced 2025-12-18 11:40:18 +01:00
add redis options to training worker
This commit is contained in:
@@ -511,7 +511,7 @@ class GraphManager(object):
|
|||||||
):
|
):
|
||||||
self.save_checkpoint()
|
self.save_checkpoint()
|
||||||
|
|
||||||
def _log_save_checkpoint(self):
|
def save_checkpoint(self):
|
||||||
checkpoint_path = os.path.join(self.task_parameters.save_checkpoint_dir,
|
checkpoint_path = os.path.join(self.task_parameters.save_checkpoint_dir,
|
||||||
"{}_Step-{}.ckpt".format(
|
"{}_Step-{}.ckpt".format(
|
||||||
self.checkpoint_id,
|
self.checkpoint_id,
|
||||||
@@ -521,6 +521,9 @@ class GraphManager(object):
|
|||||||
else:
|
else:
|
||||||
saved_checkpoint_path = checkpoint_path
|
saved_checkpoint_path = checkpoint_path
|
||||||
|
|
||||||
|
# this is required in order for agents to save additional information like a DND for example
|
||||||
|
[manager.save_checkpoint(self.checkpoint_id) for manager in self.level_managers]
|
||||||
|
|
||||||
screen.log_dict(
|
screen.log_dict(
|
||||||
OrderedDict([
|
OrderedDict([
|
||||||
("Saving in path", saved_checkpoint_path),
|
("Saving in path", saved_checkpoint_path),
|
||||||
@@ -528,12 +531,6 @@ class GraphManager(object):
|
|||||||
prefix="Checkpoint"
|
prefix="Checkpoint"
|
||||||
)
|
)
|
||||||
|
|
||||||
def save_checkpoint(self):
|
|
||||||
# this is required in order for agents to save additional information like a DND for example
|
|
||||||
[manager.save_checkpoint(self.checkpoint_id) for manager in self.level_managers]
|
|
||||||
|
|
||||||
self._log_save_checkpoint()
|
|
||||||
|
|
||||||
self.checkpoint_id += 1
|
self.checkpoint_id += 1
|
||||||
self.last_checkpoint_saving_time = time.time()
|
self.last_checkpoint_saving_time = time.time()
|
||||||
|
|
||||||
|
|||||||
@@ -29,11 +29,6 @@ def training_worker(graph_manager, checkpoint_dir):
|
|||||||
# save randomly initialized graph
|
# save randomly initialized graph
|
||||||
graph_manager.save_checkpoint()
|
graph_manager.save_checkpoint()
|
||||||
|
|
||||||
# TODO: Q: training steps passed into graph_manager.train ignored?
|
|
||||||
# TODO: specify training steps between checkpoints (in preset?)
|
|
||||||
# TODO: replace outer training loop with something general
|
|
||||||
# TODO: low priority: move evaluate out of this process
|
|
||||||
|
|
||||||
heatup(graph_manager)
|
heatup(graph_manager)
|
||||||
|
|
||||||
# training loop
|
# training loop
|
||||||
@@ -57,10 +52,21 @@ def main():
|
|||||||
help='(string) Path to a folder containing a checkpoint to write the model to.',
|
help='(string) Path to a folder containing a checkpoint to write the model to.',
|
||||||
type=str,
|
type=str,
|
||||||
default='/checkpoint')
|
default='/checkpoint')
|
||||||
|
parser.add_argument('-r', '--redis_ip',
|
||||||
|
help="(string) IP or host for the redis server",
|
||||||
|
default='localhost',
|
||||||
|
type=str)
|
||||||
|
parser.add_argument('-rp', '--redis_port',
|
||||||
|
help="(int) Port of the redis server",
|
||||||
|
default=6379,
|
||||||
|
type=int)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
graph_manager = short_dynamic_import(expand_preset(args.preset), ignore_module_case=True)
|
graph_manager = short_dynamic_import(expand_preset(args.preset), ignore_module_case=True)
|
||||||
|
|
||||||
|
graph_manager.agent_params.memory.redis_ip = args.redis_ip
|
||||||
|
graph_manager.agent_params.memory.redis_port = args.redis_port
|
||||||
|
|
||||||
training_worker(
|
training_worker(
|
||||||
graph_manager=graph_manager,
|
graph_manager=graph_manager,
|
||||||
checkpoint_dir=args.checkpoint_dir,
|
checkpoint_dir=args.checkpoint_dir,
|
||||||
|
|||||||
Reference in New Issue
Block a user