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
FrozenLake: Revise the unattainable reward_threshold to an attainable value #2205
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
**Issues:** The current `reward_threhold` for `FrozenLake-v0` and `FrozenLake8x8-v0` is too high to be attained. Commit: df515de @joschu **Solution:** Reduce the `reward_threhold` to make them attainable. **Reference:** Codes to calculate the theoretic optimal reward expectations: ```python import gym env = gym.make('FrozenLake-v0') print(env.observation_space.n) # 16 print(env.action_space.n) # 4 print(env.spec.reward_threshold) # 0.78, should be smaller print(env.spec.max_episode_steps) # 100 import numpy as np v = np.zeros((101, 16), dtype=float) q = np.zeros((101, 16, 4), dtype=float) pi = np.zeros((101, 16), dtype=float) for t in range(99, -1, -1): # backward for s in range(16): for a in range(4): for p, next_s, r, d in env.P[s][a]: q[t, s, a] += p * (r + (1. - float(d)) * v[t+1, next_s]) v[t, s] = q[t, s].max() pi[t, s] = q[t, s].argmax() print(v[0, 0]) # ~0.74 < 0.78 ``` ```python import gym env = gym.make('FrozenLake8x8-v0') print(env.observation_space.n) # 64 print(env.action_space.n) # 4 print(env.spec.reward_threshold) # 0.99, should be smaller print(env.spec.max_episode_steps) # 200 import numpy as np v = np.zeros((201, 64), dtype=float) q = np.zeros((201, 64, 4), dtype=float) pi = np.zeros((201, 64), dtype=float) for t in range(199, -1, -1): # backward for s in range(64): for a in range(4): for p, next_s, r, d in env.P[s][a]: q[t, s, a] += p * (r + (1. - float(d)) * v[t+1, next_s]) v[t, s] = q[t, s].max() pi[t, s] = q[t, s].argmax() print(v[0, 0]) # ~0.91 < 0.99 ```
ZhiqingXiao
changed the title
Revise the unattainable reward_threshold to an attainable value
FrozenLake: Revise the unattainable reward_threshold to an attainable value
Mar 28, 2021
Thanks, will merge |
Thanks for confirming and merging :) |
copybara-service bot
pushed a commit
to tensorflow/agents
that referenced
this pull request
Aug 17, 2021
…st. These changes need to go together because the build is broke due to both reasons in the past 12-24 hours. - Pillow was likely (I have not looked into that yet) being installed by another required package and is no longer a dependency of that package and thus the failure began. - OpenAI Gym is not longer loading FrozenLake-v0 and FrozenLake-v1 is new and might not be available to all users. Moving the kwargs test to use KellyCoinflip resolves the problem. Here is what happened with FrozenLake-v0: openai/gym#2205 and openai/gym#2315 PiperOrigin-RevId: 391328529 Change-Id: I09e6e962a32330b24b1fc44ebe222fb1d842d5c3
zlig
pushed a commit
to zlig/gym
that referenced
this pull request
Sep 6, 2021
…ai#2205) **Issues:** The current `reward_threhold` for `FrozenLake-v0` and `FrozenLake8x8-v0` is too high to be attained. Commit: openai@df515de @joschu **Solution:** Reduce the `reward_threhold` to make them attainable. **Reference:** Codes to calculate the theoretic optimal reward expectations: ```python import gym env = gym.make('FrozenLake-v0') print(env.observation_space.n) # 16 print(env.action_space.n) # 4 print(env.spec.reward_threshold) # 0.78, should be smaller print(env.spec.max_episode_steps) # 100 import numpy as np v = np.zeros((101, 16), dtype=float) q = np.zeros((101, 16, 4), dtype=float) pi = np.zeros((101, 16), dtype=float) for t in range(99, -1, -1): # backward for s in range(16): for a in range(4): for p, next_s, r, d in env.P[s][a]: q[t, s, a] += p * (r + (1. - float(d)) * v[t+1, next_s]) v[t, s] = q[t, s].max() pi[t, s] = q[t, s].argmax() print(v[0, 0]) # ~0.74 < 0.78 ``` ```python import gym env = gym.make('FrozenLake8x8-v0') print(env.observation_space.n) # 64 print(env.action_space.n) # 4 print(env.spec.reward_threshold) # 0.99, should be smaller print(env.spec.max_episode_steps) # 200 import numpy as np v = np.zeros((201, 64), dtype=float) q = np.zeros((201, 64, 4), dtype=float) pi = np.zeros((201, 64), dtype=float) for t in range(199, -1, -1): # backward for s in range(64): for a in range(4): for p, next_s, r, d in env.P[s][a]: q[t, s, a] += p * (r + (1. - float(d)) * v[t+1, next_s]) v[t, s] = q[t, s].max() pi[t, s] = q[t, s].argmax() print(v[0, 0]) # ~0.91 < 0.99 ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issues: The current
reward_threhold
forFrozenLake-v0
andFrozenLake8x8-v0
is too high to be attained.Commit: df515de @joschu
Solution: Reduce the
reward_threhold
to make them attainable.Reference: Codes to calculate the theoretic optimal reward expectations: