Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
baselines
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Flatland
baselines
Commits
3f36d20a
Commit
3f36d20a
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
minor updates to new prediction function
parent
2f1e8af1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
torch_training/Nets/avoid_checkpoint15000.pth
+0
-0
0 additions, 0 deletions
torch_training/Nets/avoid_checkpoint15000.pth
torch_training/training_navigation.py
+12
-8
12 additions, 8 deletions
torch_training/training_navigation.py
with
12 additions
and
8 deletions
torch_training/Nets/avoid_checkpoint15000.pth
+
0
−
0
View file @
3f36d20a
No preview for this file type
This diff is collapsed.
Click to expand it.
torch_training/training_navigation.py
+
12
−
8
View file @
3f36d20a
...
@@ -5,6 +5,8 @@ import numpy as np
...
@@ -5,6 +5,8 @@ import numpy as np
import
torch
import
torch
from
dueling_double_dqn
import
Agent
from
dueling_double_dqn
import
Agent
from
flatland.envs.generators
import
complex_rail_generator
from
flatland.envs.generators
import
complex_rail_generator
from
flatland.envs.observations
import
TreeObsForRailEnv
from
flatland.envs.predictions
import
DummyPredictorForRailEnv
from
flatland.envs.rail_env
import
RailEnv
from
flatland.envs.rail_env
import
RailEnv
from
flatland.utils.rendertools
import
RenderTool
from
flatland.utils.rendertools
import
RenderTool
...
@@ -43,10 +45,12 @@ env = RailEnv(width=10,
...
@@ -43,10 +45,12 @@ env = RailEnv(width=10,
height=20)
height=20)
env.load(
"
./railway/complex_scene.pkl
"
)
env.load(
"
./railway/complex_scene.pkl
"
)
"""
"""
env
=
RailEnv
(
width
=
8
,
height
=
8
,
env
=
RailEnv
(
width
=
20
,
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
5
,
nr_extra
=
5
,
min_dist
=
5
,
max_dist
=
99999
,
seed
=
0
),
height
=
20
,
number_of_agents
=
1
)
rail_generator
=
complex_rail_generator
(
nr_start_goal
=
10
,
nr_extra
=
1
,
min_dist
=
8
,
max_dist
=
99999
,
seed
=
0
),
obs_builder_object
=
TreeObsForRailEnv
(
max_depth
=
2
,
predictor
=
DummyPredictorForRailEnv
()),
number_of_agents
=
10
)
env
.
reset
(
True
,
True
)
env
.
reset
(
True
,
True
)
env_renderer
=
RenderTool
(
env
,
gl
=
"
PILSVG
"
)
env_renderer
=
RenderTool
(
env
,
gl
=
"
PILSVG
"
)
...
@@ -69,9 +73,9 @@ action_prob = [0] * action_size
...
@@ -69,9 +73,9 @@ action_prob = [0] * action_size
agent_obs
=
[
None
]
*
env
.
get_num_agents
()
agent_obs
=
[
None
]
*
env
.
get_num_agents
()
agent_next_obs
=
[
None
]
*
env
.
get_num_agents
()
agent_next_obs
=
[
None
]
*
env
.
get_num_agents
()
agent
=
Agent
(
state_size
,
action_size
,
"
FC
"
,
0
)
agent
=
Agent
(
state_size
,
action_size
,
"
FC
"
,
0
)
#
agent.qnetwork_local.load_state_dict(torch.load('./Nets/avoid_checkpoint1500.pth'))
agent
.
qnetwork_local
.
load_state_dict
(
torch
.
load
(
'
./Nets/avoid_checkpoint1500
0
.pth
'
))
demo
=
Fals
e
demo
=
Tru
e
def
max_lt
(
seq
,
val
):
def
max_lt
(
seq
,
val
):
"""
"""
...
@@ -143,14 +147,14 @@ for trials in range(1, n_trials + 1):
...
@@ -143,14 +147,14 @@ for trials in range(1, n_trials + 1):
score
=
0
score
=
0
env_done
=
0
env_done
=
0
# Run episode
# Run episode
for
step
in
range
(
100
):
for
step
in
range
(
env
.
height
*
env
.
width
):
if
demo
:
if
demo
:
env_renderer
.
renderEnv
(
show
=
True
,
show_observations
=
False
)
env_renderer
.
renderEnv
(
show
=
True
,
show_observations
=
False
)
# print(step)
# print(step)
# Action
# Action
for
a
in
range
(
env
.
get_num_agents
()):
for
a
in
range
(
env
.
get_num_agents
()):
if
demo
:
if
demo
:
eps
=
1
eps
=
0
# action = agent.act(np.array(obs[a]), eps=eps)
# action = agent.act(np.array(obs[a]), eps=eps)
action
=
agent
.
act
(
agent_obs
[
a
],
eps
=
eps
)
action
=
agent
.
act
(
agent_obs
[
a
],
eps
=
eps
)
action_prob
[
action
]
+=
1
action_prob
[
action
]
+=
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment