question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `reward` and `observation` arguments to env.reset()

See original GitHub issue

🚀 Feature

The CompilerEnv constructor accepts a pair of arguments reward_space and observation_space. We should add those to env.reset(), same as specifying the benchmark.

Motivation

Because this feels like a clumsy API:

env.reward_space = "Foobar"
env.reset(benchmark="benchmark://foo-v0/abc")

Pitch

Allow:

env.reset(benchmark="benchmark://foo-v0/abc", reward_space="Foobar")

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
udusecommented, Feb 4, 2022
env.reset(
    benchmark=compiler_gym.ValueNotChanged,
    reward_space="some_new_space",
    observation_space=None,  # no observations
)

This seems good to me. Alternatively, we could use python’s ellipsis ... as this special placeholder, or just the string "same". Personally I prefer just "same" because it’s simple, explicit, easy to understand, and immutable which makes it a good choice as the default value.

0reactions
ChrisCumminscommented, Apr 1, 2022

I’m also not sure I like the default being the string "same", as it doesn’t feel particularly self-documenting, and prevents the (unlikely) use of the name “same” with observation/reward spaces.

I would suggest adding a new enum to compiler_gym/util/gym_type_hints.py

from enum import Enum

class OptionalArgumentValue(Enum):
    UNCHANGED = 1

The OptionalArgumentValue.UNCHANGED could be used as the default value and checked for using:

if reward_space != OptionalArgumentValue.UNCHANGED:
    ...

Cheers, Chris

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing arguments to env.reset() function without modifying ...
Hi, I need to pass some args when reseting my gym environment (wrapped by GymEnvWrapper) at the begin of the evaluation phase and...
Read more >
Getting Started With OpenAI Gym: The Basic Building Blocks
The reset function returns four things: observation : The observation of the state of the environment. reward : The reward that you can...
Read more >
Environments • reinforcelearn - markusdumke
reset() : Resets the environment, i.e. it sets the state attribute to a starting state and sets the done flag to FALSE ....
Read more >
How to set a openai-gym environment start with a specific ...
How can I tell the gym.env that I want set the initial observation as ns and let the agent know the specific start...
Read more >
Reinforcement Learning: Creating a Custom Environment
reset() : Resets all state-based environment variables to their initial state and returns the initial observation. step() : Defines what the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found