Skip to content

Commit

Permalink
Fix NStepBatchSampler sampling out of bounds indicies
Browse files Browse the repository at this point in the history
When stacksize > 1, NStepBatchSampler samples inds < stacksize, which causes out of bounds errors.
  • Loading branch information
ludvigk authored Sep 13, 2024
1 parent de01fb3 commit 4faf656
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/samplers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function valid_range(s::NStepBatchSampler, eb::EpisodesBuffer)
stacksize = isnothing(s.stacksize) ? 1 : s.stacksize
for idx in eachindex(range)
step_number = eb.step_numbers[idx]
range[idx] = step_number >= stacksize && eb.sampleable_inds[idx]
range[idx] = step_number >= stacksize && eb.sampleable_inds[idx] && idx >= stacksize
ns[idx] = min(s.n, eb.episodes_lengths[idx] - step_number + 1)
end
return range, ns
Expand Down

0 comments on commit 4faf656

Please sign in to comment.