How can I best set the seed of my environments while training an RL agent?
I found the following answer on stack overflow Obtaining different set of configs across multiple calls in ray tune - Stack Overflow and here python 3.x - How do I make ray.tune.run reproducible? - Stack Overflow.
From which I understood that…
Function-level API cannot be made reproducible (ray v1.1.0, may be subject to change).
That’s why it seems I need to use the Class API for Trainanble instead of the function API. But I am not sure how to transform my current function into a tune.Trainable sub class :
def my_train_fn(config, reporter):
agent = TD3Trainer(config=config, env="guidance-v0") for i in range(NUM_EPISODES): result = agent.train() if i % 1 == 0: checkpoint = agent.save(checkpoint_dir="./data/checkpoints") # print(pretty_print(result)) print("checkpoint saved at", checkpoint) agent.stop()
tune.run(my_train_fn, resources_per_trial=resources, config=config)