Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
neurips2020-flatland-starter-kit
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Contributor 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
adrian_egli
neurips2020-flatland-starter-kit
Commits
52a015e1
Commit
52a015e1
authored
4 years ago
by
Egli Adrian (IT-SCI-API-PFI)
Browse files
Options
Downloads
Patches
Plain Diff
refactored and added new agent
parent
03748921
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
reinforcement_learning/multi_agent_training.py
+1
-1
1 addition, 1 deletion
reinforcement_learning/multi_agent_training.py
reinforcement_learning/ppo_agent.py
+5
-6
5 additions, 6 deletions
reinforcement_learning/ppo_agent.py
with
6 additions
and
7 deletions
reinforcement_learning/multi_agent_training.py
+
1
−
1
View file @
52a015e1
...
...
@@ -172,7 +172,7 @@ def train_agent(train_params, train_env_params, eval_env_params, obs_params):
# Double Dueling DQN policy
policy
=
DDDQNPolicy
(
state_size
,
get_action_size
(),
train_params
)
if
Fals
e
:
if
Tru
e
:
policy
=
PPOAgent
(
state_size
,
get_action_size
())
if
False
:
policy
=
DeadLockAvoidanceAgent
(
train_env
,
get_action_size
())
...
...
This diff is collapsed.
Click to expand it.
reinforcement_learning/ppo_agent.py
+
5
−
6
View file @
52a015e1
...
...
@@ -166,11 +166,6 @@ class PPOAgent(Policy):
if
self
.
use_replay_buffer
:
self
.
memory
.
add
(
state_i
,
action_i
,
discounted_reward
,
state_next_i
,
done_i
)
if
self
.
use_replay_buffer
:
if
len
(
self
.
memory
)
>
self
.
buffer_min_size
and
len
(
self
.
memory
)
>
self
.
batch_size
:
states
,
actions
,
rewards
,
next_states
,
dones
,
prob_actions
=
self
.
memory
.
sample
()
return
states
,
actions
,
rewards
,
next_states
,
dones
,
prob_actions
# convert data to torch tensors
states
,
actions
,
rewards
,
states_next
,
dones
,
prob_actions
=
\
torch
.
tensor
(
state_list
,
dtype
=
torch
.
float
).
to
(
self
.
device
),
\
...
...
@@ -195,7 +190,11 @@ class PPOAgent(Policy):
states
,
actions
,
rewards
,
states_next
,
dones
,
probs_action
=
\
self
.
_convert_transitions_to_torch_tensors
(
agent_episode_history
)
# Optimize policy for K epochs:
for
_
in
range
(
int
(
self
.
K_epoch
)):
for
k_loop
in
range
(
int
(
self
.
K_epoch
)):
if
self
.
use_replay_buffer
and
k_loop
>
0
:
if
len
(
self
.
memory
)
>
self
.
buffer_min_size
and
len
(
self
.
memory
)
>
self
.
batch_size
:
states
,
actions
,
rewards
,
states_next
,
dones
,
probs_action
=
self
.
memory
.
sample
()
# Evaluating actions (actor) and values (critic)
logprobs
,
state_values
,
dist_entropy
=
self
.
actor_critic_model
.
evaluate
(
states
,
actions
)
...
...
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