# Changing RL Experiment Arguments

**URL:** <https://discourse.julialang.org/t/changing-rl-experiment-arguments/93856>\
**Category:** Machine Learning\
**Created:** [February 1, 2023, 8:26am UTC](https://discourse.julialang.org/t/changing-rl-experiment-arguments/93856 "2023-02-01T08:26:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeB](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikeb/32/46396_2.png) [@MikeB](https://discourse.julialang.org/u/MikeB)\
**Post date:** [February 1, 2023, 8:26am UTC](https://discourse.julialang.org/t/changing-rl-experiment-arguments/93856/1 "2023-02-01T08:26:53Z")

</div>

This is kind of embarrassing, but, I can’t figure out how to change the seed=123 argument on the DQN\_Cartpole experiment.

I threw the code into a Jupyter notebook, with the function in one big cell, then the `ex=E'JuliaRL_BasicDQN_CartPole'` and `run(ex)` each in their own cell. Everything runs fine but I want to add more arguments to the function and I can’t figure out how the function is called…

Among other things, I’ve tried:

- `run(ex, seed=42)`
- `run(ex(seed=42)`
- `run(run(ex), seed=42)`
- `ex=E`JuliaRL\_BasicDQN\_CartPole`, seed=42`

I **hate** being back to a newbie with a language!

Thanks!

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [February 1, 2023, 9:06am UTC](https://discourse.julialang.org/t/changing-rl-experiment-arguments/93856/2 "2023-02-01T09:06:52Z")

</div>

I think the way to call this with the additional arguments is either

```julia
ex = E`JuliaRL_DQN_CartPole(seed=37)`

```

if you want to use the string macros (personally I think they mostly confuse things) or

```julia
ex = Experiment(Val(:JuliaRL), Val(:DQN), Val(:CartPole), nothing; seed=37)

```

if you want to use the method call.

If you want to change more things though, I would copy the env into my own function so I can mess with it best I want. So starting from the base file here

> <https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/blob/master/src/ReinforcementLearningExperiments/deps/experiments/experiments/DQN/JuliaRL_DQN_CartPole.jl>

you can set up a function to generate your experiment something like this

```julia
function my_experiment(;
    seed=123,
    n=1,
    γ=0.99f0,
    is_enable_double_DQN=true
)
    rng = StableRNG(seed)
    env = CartPoleEnv(; T=Float32, rng=rng)
    ns, na = length(state(env)), length(action_space(env))

    agent = Agent(
        ...
    )

    stop_condition = StopAfterStep(10_000, is_show_progress=!haskey(ENV, "CI"))
    hook = TotalRewardPerEpisode()
    Experiment(agent, env, stop_condition, hook)
end

ex = my_experiment(; seed=37)
run(ex)

```
