-
Notifications
You must be signed in to change notification settings - Fork 13
Update README and dependencies. #3
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,25 @@ | ||
| import os, sys | ||
| import fastText | ||
| import fasttext | ||
| sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
| from valid_detector import ValidDetector | ||
| import gv | ||
| import util | ||
|
|
||
| # Monkey patch to remove warning message in fasttext 0.9.2. | ||
| # Ref: https://github.com/facebookresearch/fastText/issues/1067 | ||
| fasttext.FastText.eprint = lambda x: None | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed until 0.9.3 comes out. |
||
|
|
||
| model_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
| "valid_model.bin") | ||
|
|
||
| class LearnedValidDetector(ValidDetector): | ||
| """ | ||
| Uses a fastText classifier to predict the validity of the response text. | ||
| Uses a fasttext classifier to predict the validity of the response text. | ||
|
|
||
| """ | ||
| def __init__(self): | ||
| super().__init__() | ||
| self.model = fastText.load_model(model_path) | ||
| self.model = fasttext.load_model(model_path) | ||
|
|
||
| def action_valid(self, action, response_text): | ||
| if not util.action_recognized(action, response_text): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,6 @@ | ||
| certifi==2018.10.15 | ||
| chardet==3.0.4 | ||
| cymem==2.0.2 | ||
| cytoolz==0.9.0.1 | ||
| dill==0.2.8.2 | ||
| en-core-web-sm==2.0.0 | ||
| fasttext==0.8.22 | ||
| fuzzywuzzy==0.17.0 | ||
| idna==2.7 | ||
| jericho==1.1.1 | ||
| msgpack==0.5.6 | ||
| msgpack-numpy==0.4.3.2 | ||
| murmurhash==1.0.1 | ||
| numpy==1.15.3 | ||
| pkg-resources==0.0.0 | ||
| plac==0.9.6 | ||
| preshed==2.0.1 | ||
| pybind11==2.2.4 | ||
| python-Levenshtein==0.12.0 | ||
| regex==2018.1.10 | ||
| requests==2.20.0 | ||
| six==1.11.0 | ||
| spacy==2.0.16 | ||
| thinc==6.12.0 | ||
| toolz==0.9.0 | ||
| tqdm==4.28.1 | ||
| ujson==1.35 | ||
| urllib3==1.24 | ||
| wrapt==1.10.11 | ||
| spacy==3.1.1 | ||
| fasttext==0.9.2 | ||
| jericho==3.0.5 | ||
| numpy==1.20.3 | ||
| python-Levenshtein==0.12.2 | ||
| fuzzywuzzy==0.18.0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,31 +28,37 @@ def main(): | |
| agent = NailAgent(seed=args.seed, env=env, rom_name=os.path.basename(args.game)) | ||
|
|
||
| # Get the first observation from the environment. | ||
| obs = env.reset() | ||
| obs, info = env.reset() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reflects Jericho's API changes. |
||
|
|
||
| # Keep track of the maximum score achieved. | ||
| max_score = 0 | ||
|
|
||
| # Run the agent on the environment for the specified number of steps. | ||
| for step_num in range(args.steps): | ||
| # Get one action from the agent. | ||
| action = agent.take_action(obs) | ||
|
|
||
| # Pass the action to the environment. | ||
| new_obs, score, done, info = env.step(action) | ||
| new_obs, reward, done, info = env.step(action) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The step method now returns the immediate reward instead of the current score. |
||
| max_score = max(info["score"], max_score) | ||
|
|
||
| # Update the agent. | ||
| agent.observe(obs, action, score, new_obs, done) | ||
| agent.observe(obs, action, reward, new_obs, done) | ||
| obs = new_obs | ||
|
|
||
| # Output this step. | ||
| print("Step {} Action [{}] Score {}\n{}".format(step_num, action, score, obs)) | ||
| print("Step {} Action [{}] Score {}\n{}".format(step_num, action, info["score"], obs)) | ||
|
|
||
| # Check for done (such as on death). | ||
| if done: | ||
| print("Environment returned done=True. So reset the environment.\n") | ||
| obs = env.reset() | ||
| obs, info = env.reset() | ||
|
|
||
| # Clean up the agent. | ||
| agent.finalize() | ||
|
|
||
| print(f"Max score achieved: {max_score}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some issues I found with the latest spacy version.