Skip to content
This repository was archived by the owner on May 21, 2022. It is now read-only.

Speed part 1#11

Merged
iblislin merged 5 commits intoJuliaML:masterfrom
JobJob:speed
Nov 4, 2018
Merged

Speed part 1#11
iblislin merged 5 commits intoJuliaML:masterfrom
JobJob:speed

Conversation

@JobJob
Copy link
Copy Markdown
Member

@JobJob JobJob commented Sep 15, 2018

Adds a state type param, improves type inference, and speed.

Requires JuliaML/Reinforce.jl/pull/23

This builds on #10

@iblislin
Copy link
Copy Markdown
Member

iblislin commented Nov 2, 2018

okay, next one is this.
but i'm going to 💤 first.

Comment thread src/OpenAIGym.jl Outdated
Comment thread src/OpenAIGym.jl Outdated
Comment thread src/OpenAIGym.jl Outdated
Comment thread src/OpenAIGym.jl
@codecov-io
Copy link
Copy Markdown

codecov-io commented Nov 4, 2018

Codecov Report

Merging #11 into master will increase coverage by 9.13%.
The diff coverage is 91.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #11      +/-   ##
==========================================
+ Coverage   51.28%   60.41%   +9.13%     
==========================================
  Files           1        1              
  Lines          39       48       +9     
==========================================
+ Hits           20       29       +9     
  Misses         19       19
Impacted Files Coverage Δ
src/OpenAIGym.jl 60.41% <91.3%> (+9.13%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6e27aa...67df22c. Read the comment docs.

Comment thread src/OpenAIGym.jl Outdated
Comment thread test/runtests.jl Outdated
pacmannf = GymEnv("MsPacmanNoFrameskip-v4")
cartpole = GymEnv("CartPole-v0")
bj = GymEnv("Blackjack-v0")
bj = GymEnv("Blackjack-v0", stateT=PyAny)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried stateT = PyVector and it works.
Is there any significant difference if I use PyVector?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what context?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performance

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For BlackJack, I don't know - I'll check.

As a default for envs? PyArray will be much quicker I believe, because getindex(::PyArray, ...) is just a pointer lookup. It's also much more appropriate for, e.g., atari games, which return images (frames from the screen).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyVector is faster than PyAny for just stepping the environment:

Trial 1 (PyVector one is the second one):
env.pyenv: PyObject <gym.envs.toy_text.blackjack.BlackjackEnv object at 0x1266ec470> num_eps: 30000 t: 0.9989846660000005 steps: 41180
microsecs/step (lower is better): 24.25897683341429
------------------------------
env.pyenv: PyObject <gym.envs.toy_text.blackjack.BlackjackEnv object at 0x1266f95c0> num_eps: 30000 t: 0.7416911469999994 steps: 41335
microsecs/step (lower is better): 17.943417128341586

Trial 2:
env.pyenv: PyObject <gym.envs.toy_text.blackjack.BlackjackEnv object at 0x129ae4a20> num_eps: 30000 t: 0.8304164830000038 steps: 41227
microsecs/step (lower is better): 20.142539670604307
------------------------------
env.pyenv: PyObject <gym.envs.toy_text.blackjack.BlackjackEnv object at 0x129ae4b70> num_eps: 30000 t: 0.737025869000004 steps: 41307
microsecs/step (lower is better): 17.842638511632508

dunno about doing stuff with the PyVector, as compared to the Tuple{Int64,Int64,Bool}, but don't really care either :trollface:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Copy link
Copy Markdown
Member Author

@JobJob JobJob Nov 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw blackjack is faster than python in these benchmarks because the env.step is so quick that julia's advantage in loop speed becomes a factor

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least I figure that's what's happening.

Comment thread src/OpenAIGym.jl Outdated
Comment thread src/OpenAIGym.jl Outdated
BlackJack can't be converted to PyArray, all other Gym envs can :/
@iblislin iblislin merged commit 6f525bc into JuliaML:master Nov 4, 2018
@JobJob
Copy link
Copy Markdown
Member Author

JobJob commented Nov 4, 2018

🎉 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants