Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing kwargs to tensorforce environment via Runner #875

Open
rolandrmgservices opened this issue Jun 23, 2022 · 0 comments
Open

passing kwargs to tensorforce environment via Runner #875

rolandrmgservices opened this issue Jun 23, 2022 · 0 comments

Comments

@rolandrmgservices
Copy link

Thanks for such a useful codebase. I had a question re customizing environment creation via the runner class.

Say we have an environment like the ThermostatEnvironment defined in: https://github.com/tensorforce/tensorforce/blob/master/examples/temperature-controller.ipynb

but the constructor takes tau as a parameter:

    def __init__(self, tau):
        ## Some initializations.  Will eventually parameterize this in the constructor.
        self.tau = tau
        self.current_temp = np.random.random(size=(1,))

        super().__init__()

We then want to run this environment with the Runner, like:

    ...
    runner = Runner(agent=agent, environment=ThermostatEnvironment, num_parallel=4)
    runner.run(num_episodes=100, batch_agent_calls=True)
    runner.close()

But we want to configure the environment with a different tau for a variety of different runs. So ideally we could do something like:

    ...
    runner = Runner(agent=agent, environment=ThermostatEnvironment, num_parallel=4, tau=3.0)
    runner.run(num_episodes=100, batch_agent_calls=True)
    runner.close()

    ...
    runner = Runner(agent=agent, environment=ThermostatEnvironment, num_parallel=4, tau=6.0)
    runner.run(num_episodes=100, batch_agent_calls=True)
    runner.close()

However, the Runner constructor doesn't pass kwargs to the Environment.create in:

environment = Environment.create(
environment=environments[0], max_episode_timesteps=max_episode_timesteps,
remote=remote, blocking=blocking, host=host[0], port=port[0]
)

Given the above, is there a way to pass keywords through to customize the Tensorforce environment that is being created by the runner? I saw that it is possible to define a spec via JSON, but this would require writing different JSON files for each environment variation to be created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant