I would like to run the following code but instead of Cartpole use a custom environment:
import ray
import ray.rllib.agents.dqn.apex as apex
from ray.tune.logger import pretty_print
def train_cartpole() -> None:
ray.init()
config = apex.APEX_DEFAULT_CONFIG.copy()
config["num_gpus"] = 0
config["num_workers"] = 3
trainer = apex.ApexTrainer(config=config, env="CartPole-v0")
for _ in range(1000):
# Perform one iteration of training the policy with Apex-DQN
result = trainer.train()
print(pretty_print(result))
train_cartpole()
My environment is defined as a gym.Env class and I want to create it using gym.make and then apply a wrapper to it and gym's FlattenObservation(). I have found ways of providing the environment as a class or a string, but that does not work for me because I do not know how to apply the wrappers afterwards.