-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed DQNLearner Gpu isse * reanme variables for cspell / conventions
- Loading branch information
Showing
4 changed files
with
79 additions
and
6 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
src/ReinforcementLearningExperiments/deps/experiments/experiments/DQN/DQN_CartPoleGPU.jl
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# --- | ||
# title: JuliaRL\_DQNCartPole\_GPU | ||
# cover: | ||
# description: DQN applied to CartPole on GPU | ||
# date: 2023-07-24 | ||
# author: "[Panajiotis Keßler](mailto:[email protected])" | ||
# --- | ||
|
||
function RLCore.Experiment( | ||
::Val{:JuliaRL}, | ||
::Val{:DQNCartPole}, | ||
::Val{:GPU}, | ||
seed=123, | ||
cap = 100, | ||
n=12, | ||
γ=0.99f0 | ||
) | ||
rng = StableRNG(seed) | ||
env = CartPoleEnv(; T = Float32, rng = rng) | ||
ns, na = length(state(env)), length(action_space(env)) | ||
|
||
policy = Agent( | ||
QBasedPolicy( | ||
learner=DQNLearner( | ||
approximator=Approximator( | ||
model=TwinNetwork( | ||
Chain( | ||
Dense(ns, 128, relu; init = glorot_uniform(rng)), | ||
Dense(128, 128, relu; init = glorot_uniform(rng)), | ||
Dense(128, na; init = glorot_uniform(rng)), | ||
); | ||
sync_freq=100 | ||
), | ||
optimiser=Adam(), | ||
) |> gpu, | ||
n=n, | ||
γ=γ, | ||
is_enable_double_DQN=true, | ||
loss_func=huber_loss, | ||
rng=rng, | ||
), | ||
explorer=EpsilonGreedyExplorer( | ||
kind=:exp, | ||
ϵ_stable=0.01, | ||
decay_steps=500, | ||
rng=rng, | ||
), | ||
), | ||
Trajectory( | ||
container=CircularArraySARTTraces( | ||
capacity=cap, | ||
state=Float32 => (ns), | ||
), | ||
sampler=NStepBatchSampler{SS′ART}( | ||
n=n, | ||
γ=0.99f0, | ||
batch_size=32, | ||
rng=rng | ||
), | ||
controller=InsertSampleRatioController( | ||
threshold=ceil(1.1*n), | ||
n_inserted=0 | ||
)), | ||
) | ||
stop_condition = StopAfterEpisode(5, is_show_progress=!haskey(ENV, "CI")) | ||
hook = TotalRewardPerEpisode() | ||
Experiment(policy, env, stop_condition, hook) | ||
end |
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
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
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