From 73f2efb0a4de800362cf5c2caddcc46b276b8776 Mon Sep 17 00:00:00 2001 From: Dharanish Date: Thu, 9 May 2024 11:21:32 +0200 Subject: [PATCH] Fix sampling of CircularPrioritizedTraces --- src/samplers.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/samplers.jl b/src/samplers.jl index 8701189..e5443a7 100644 --- a/src/samplers.jl +++ b/src/samplers.jl @@ -74,7 +74,7 @@ function StatsBase.sample(s::BatchSampler, e::EpisodesBuffer{<:Any, <:Any, <:Cir t = e.traces p = collect(deepcopy(t.priorities)) w = StatsBase.FrequencyWeights(p) - w .*= e.sampleable_inds[1:end-1] + w .*= e.sampleable_inds[1:length(t)] inds = StatsBase.sample(s.rng, eachindex(w), w, s.batchsize) NamedTuple{(:key, :priority, names...)}((t.keys[inds], p[inds], map(x -> collect(t.traces[Val(x)][inds]), names)...)) end @@ -247,7 +247,7 @@ function StatsBase.sample(s::NStepBatchSampler{names}, e::EpisodesBuffer{<:Any, p = collect(deepcopy(t.priorities)) w = StatsBase.FrequencyWeights(p) valids, ns = valid_range(s,e) - w .*= valids[1:end-1] + w .*= valids[1:length(t)] inds = StatsBase.sample(s.rng, eachindex(w), w, s.batchsize) merge( (key=t.keys[inds], priority=p[inds]), @@ -362,7 +362,7 @@ function StatsBase.sample(s::MultiStepSampler{names}, e::EpisodesBuffer{<:Any, < p = collect(deepcopy(t.priorities)) w = StatsBase.FrequencyWeights(p) valids, ns = valid_range(s,e) - w .*= valids[1:end-1] + w .*= valids[1:length(t)] inds = StatsBase.sample(s.rng, eachindex(w), w, s.batchsize) merge( (key=t.keys[inds], priority=p[inds]),