Skip to content

Commit

Permalink
Update examples that use model instantiators to the latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni-SM committed Jan 7, 2025
1 parent 4a03a91 commit 8eeaa41
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 96 deletions.
26 changes: 14 additions & 12 deletions docs/source/examples/gym/jax_gym_cartpole_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# instantiate models' state dict
for role, model in models.items():
Expand Down
26 changes: 14 additions & 12 deletions docs/source/examples/gym/jax_gym_cartpole_vector_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# instantiate models' state dict
for role, model in models.items():
Expand Down
26 changes: 14 additions & 12 deletions docs/source/examples/gym/torch_gym_cartpole_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# initialize models' lazy modules
for role, model in models.items():
Expand Down
26 changes: 14 additions & 12 deletions docs/source/examples/gym/torch_gym_cartpole_vector_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# initialize models' lazy modules
for role, model in models.items():
Expand Down
26 changes: 14 additions & 12 deletions docs/source/examples/gymnasium/jax_gymnasium_cartpole_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# instantiate models' state dict
for role, model in models.items():
Expand Down
26 changes: 14 additions & 12 deletions docs/source/examples/gymnasium/jax_gymnasium_cartpole_vector_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# instantiate models' state dict
for role, model in models.items():
Expand Down
26 changes: 14 additions & 12 deletions docs/source/examples/gymnasium/torch_gymnasium_cartpole_dqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# initialize models' lazy modules
for role, model in models.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,24 @@
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")
models["target_q_network"] = deterministic_model(observation_space=env.observation_space,
action_space=env.action_space,
device=device,
clip_actions=False,
input_shape=Shape.OBSERVATIONS,
hiddens=[64, 64],
hidden_activation=["relu", "relu"],
output_shape=Shape.ACTIONS,
output_activation=None,
output_scale=1.0)
network=[{
"name": "net",
"input": "STATES",
"layers": [64, 64],
"activations": "relu",
}],
output="ACTIONS")

# initialize models' lazy modules
for role, model in models.items():
Expand Down

0 comments on commit 8eeaa41

Please sign in to comment.