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

Reinforcement Learning Examples #284

Closed
wants to merge 20 commits into from

Conversation

ozanarkancan
Copy link
Collaborator

@ozanarkancan ozanarkancan commented Mar 12, 2018

Hi,

I am starting this pull request for reinforcement learning examples. I have implemented followings:

  • Value Iteration, Policy Evaluation, Policy Iteration
  • REINFORCE for both discrete and continuous action spaces

My TODO list

  • DQN
  • Actor Critic

@ozanarkancan ozanarkancan changed the title Rl Reinforcement Learning Examples Mar 12, 2018
push!(rewards, reward[1])
push!(actions, action[1])

if o["render"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

o["render"] && render(env) for conciseness?

render(env)
end

if done
Copy link
Collaborator

Choose a reason for hiding this comment

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

done && break

return f1 * x + f2 * abs.(x)
end

function predict_linear(w, ob)
Copy link
Collaborator

Choose a reason for hiding this comment

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

predict_probs or probs or predict instead of predict_linear?


function sample_action(μ; σ=1.0)
μ = convert(Array{Float32}, μ)
a = μ + randn() * σ
Copy link
Collaborator

Choose a reason for hiding this comment

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

randn(size(μ)) instead of randn()

Copy link
Collaborator

Choose a reason for hiding this comment

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

also use .+ and .*

@CarloLucibello
Copy link
Collaborator

the package Gym should be submitted to METADATA before merging this

@CarloLucibello
Copy link
Collaborator

CarloLucibello commented Mar 12, 2018

I coded here some actor-critic examples https://github.com/CarloLucibello/DeepRLexamples.jl, feel free to utilize any piece of code in case you find it of some use

@ereday
Copy link
Collaborator

ereday commented Mar 18, 2018

There is a typo in all examples (like this and this) . I guess pkb should be pkg

@ozanarkancan
Copy link
Collaborator Author

fixed

@ereday
Copy link
Collaborator

ereday commented Mar 18, 2018

Now, actor_critic_discrete.jl complains about Gym initialization.

ERROR: LoadError: InitError: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)
Stacktrace:
 [1] pyerr_check at /home/erenay/.julia/v0.6/PyCall/src/exception.jl:56 [inlined]
 [2] pyerr_check at /home/erenay/.julia/v0.6/PyCall/src/exception.jl:61 [inlined]
 [3] macro expansion at /home/erenay/.julia/v0.6/PyCall/src/exception.jl:81 [inlined]
 [4] pyimport(::String) at /home/erenay/.julia/v0.6/PyCall/src/PyCall.jl:374
 [5] __init__() at /home/erenay/.julia/v0.6/Gym/src/Gym.jl:10
 [6] _include_from_serialized(::String) at ./loading.jl:157
 [7] _require_from_serialized(::Int64, ::Symbol, ::String, ::Bool) at ./loading.jl:200
 [8] _require(::Symbol) at ./loading.jl:498
 [9] require(::Symbol) at ./loading.jl:405
 [10] include_from_node1(::String) at ./loading.jl:576
 [11] include(::String) at ./sysimg.jl:14
 [12] process_options(::Base.JLOptions) at ./client.jl:305
 [13] _start() at ./client.jl:371
during initialization of module Gym
while loading /home/erenay/.julia/v0.6/Knet/examples/actor_critic_discrete.jl, in expression starting on line 22

@ereday
Copy link
Collaborator

ereday commented Mar 18, 2018

It works now. @denizyuret examples work. It can be merged.

@denizyuret
Copy link
Owner

  • Notebooks get too big with plots, in Knet I am committing versions of all notebooks with text outputs but without plots (2.5M -> 28K). I did a fresh copy into master as we don't want the 2M files in git history either. (Another alternative is to save with plots under its own package in KnetML). Please continue development under current master.
  • In the dp notebook GYM_ENVS should be in quotes -- fixed.
  • In the dp notebook I get a "WARNING: special characters "#{}()[]<>|&*?~;" should now be quoted in commands" during Pkg.build("Gym"), don't know if it hurts anything.
  • In the dp notebook env = GymEnv("FrozenLake-v0") gives error 'No module named scipy.stats', is there any way scipy can be automatically installed during Pkg.build? Please test with fresh python without preinstalled packages.
  • In reinforce I get the following in the last box: 'WARN: gym.spaces.Box autodetected dtype as <type 'numpy.float32'>. Please provide explicit dtype.', is this something we can fix?
  • I haven't been able to run dqn yet, it hangs at DQN.main("--help"), maybe I am not giving it enough memory?

@ozanarkancan
Copy link
Collaborator Author

  • I guess "WARNING: special characters "#{}()[]<>|&*?~;" is related with a julia issue
  • scipy is in the requirements of gym but somehow it is not triggered during the installation. I will investigate it.
  • 'WARN: gym.spaces.Box autodetected dtype as <type 'numpy.float32'> is coming from gym even if you use it in python.
  • The last one might be a notebook issue, julia dqn.jl --printinfo should work.

@denizyuret
Copy link
Owner

denizyuret commented Mar 18, 2018 via email

denizyuret added a commit that referenced this pull request Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants