Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/algorithms/dqns/iqn.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function (learner::IQNLearner)(obs)
τ = rand(learner.device_rng, Float32, learner.K, 1)
τₑₘ = embed(τ, learner.Nₑₘ)
quantiles = learner.approximator(state, τₑₘ)
vec(sum(quantiles; dims = 2)) |> send_to_host
vec(mean(quantiles; dims = 2)) |> send_to_host
end

embed(x, Nₑₘ) = cos.(Float32(π) .* (1:Nₑₘ) .* reshape(x, 1, :))
Expand All @@ -184,9 +184,10 @@ function RLBase.update!(learner::IQNLearner, batch::NamedTuple)
τ′ = rand(learner.device_rng, Float32, N′, batch_size) # TODO: support β distribution
τₑₘ′ = embed(τ′, Nₑₘ)
zₜ = Zₜ(s′, τₑₘ′)
aₜ = argmax(zₜ; dims = 1) # risk-sensitive
qₜ = reshape(zₜ[aₜ], N′, batch_size) # view?
target = reshape(r, 1, batch_size) .+ reshape(1 .- t, 1, batch_size) .* qₜ # reshape to allow broadcast
aₜ = argmax(mean(zₜ, dims = 2), dims = 1)
aₜ = aₜ .+ typeof(aₜ)(CartesianIndices((0, 0:N′-1, 0)))
qₜ = reshape(zₜ[aₜ], :, batch_size)
target = reshape(r, 1, batch_size) .+ learner.γ * reshape(1 .- t, 1, batch_size) .* qₜ # reshape to allow broadcast
Comment on lines +187 to +190
Copy link
Member

Choose a reason for hiding this comment

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

👍 👍 👍


τ = rand(learner.device_rng, Float32, N, batch_size)
τₑₘ = embed(τ, Nₑₘ)
Expand Down
2 changes: 1 addition & 1 deletion src/experiments/atari.jl
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function RLCore.Experiment(
stop_condition = StopAfterStep(N_TRAINING_STEPS)

description = """
This experiment uses alomost the same config in [dopamine](https://github.com/google/dopamine/blob/master/dopamine/agents/dqn/configs/dqn.gin). But do notice that there are some minor differences:
This experiment uses almost the same config in [dopamine](https://github.com/google/dopamine/blob/master/dopamine/agents/dqn/configs/dqn.gin). But do notice that there are some minor differences:

- The RMSProp in Flux do not support center option (also the epsilon is not the same).
- The image resize method used here is provided by ImageTransformers, which is not the same with the one in cv2.
Expand Down