# BoundsError: attempt to access 2-element Vector in DDPG algorithm

**URL:** <https://discourse.julialang.org/t/boundserror-attempt-to-access-2-element-vector-in-ddpg-algorithm/62574>\
**Category:** Machine Learning\
**Tags:** question, machine-learning\
**Created:** [June 8, 2021, 12:03pm UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-2-element-vector-in-ddpg-algorithm/62574 "2021-06-08T12:03:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GK\_197](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@GK\_197](https://discourse.julialang.org/u/GK_197)\
**Post date:** [June 8, 2021, 12:03pm UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-2-element-vector-in-ddpg-algorithm/62574/1 "2021-06-08T12:03:01Z")

</div>

Hi,

I was implementing DDPG algorithm for 1-D vector action space but, during run it shows error as:

`BoundsError: attempt to access 2-element Vector{Float64} at index []`

Now, when looked into DDPG policy on Github

```julia
# TODO: handle Training/Testing mode
function (p::DDPGPolicy)(env)
    p.step += 1

    if p.step <= p.start_steps
        p.start_policy(env)
    else
        D = device(p.behavior_actor)
        s = state(env)
        s = Flux.unsqueeze(s, ndims(s) + 1)
        action = p.behavior_actor(send_to_device(D, s)) |> vec |> send_to_host
        clamp(action[] + randn(p.rng) * p.act_noise, -p.act_limit, p.act_limit)
    end
end

```

It has `action[]`, so is it expecting action to be scalar. As we have action\_space of form `[1..3,2..3]`.  
I am using start policy in DDPG agent as -

`start_policy = RandomPolicy(action_space(env);rng)`

Any help or suggestion on how this is usually done is appreciated! 😃

---

<div class="post-metadata">

**Author:** ![findmyway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/findmyway/32/4946_2.png) [@findmyway](https://discourse.julialang.org/u/findmyway)\
**Post date:** [June 14, 2021, 4:21am UTC](https://discourse.julialang.org/t/boundserror-attempt-to-access-2-element-vector-in-ddpg-algorithm/62574/2 "2021-06-14T04:21:05Z")

</div>

Ah, it’s still not fixed yet after a year…

> <https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/issues/138>
>
> Currently only scalar actions are supported, how far up on the priority list is …it to expand on this?
