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
xzhaoma
baselines
Commits
3d1219e3
Commit
3d1219e3
authored
5 years ago
by
Erik Nygren
Browse files
Options
Downloads
Patches
Plain Diff
Commented functions for better understanding
parent
21dba5da
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
utils/observation_utils.py
+19
-6
19 additions, 6 deletions
utils/observation_utils.py
with
19 additions
and
6 deletions
utils/observation_utils.py
+
19
−
6
View file @
3d1219e3
...
...
@@ -50,12 +50,19 @@ def norm_obs_clip(obs, clip_min=-1, clip_max=1):
def
split_tree
(
tree
,
num_features_per_node
=
8
,
current_depth
=
0
):
"""
:param tree:
:param num_features_per_node:
:param prompt:
:param current_depth:
:return:
Splits the tree observation into different sub groups that need the same normalization.
This is necessary because the tree observation includes two different distance:
1. Distance from the agent --> This is measured in cells from current agent location
2. Distance to targer --> This is measured as distance from cell to agent target
3. Binary data --> Contains information about presence of object --> No normalization necessary
Number 1. will depend on the depth and size of the tree search
Number 2. will depend on the size of the map and thus the max distance on the map
Number 3. Is independent of tree depth and map size and thus must be handled differently
Therefore we split the tree into these two classes for better normalization.
:param tree: Tree that needs to be split
:param num_features_per_node: Features per node ATTENTION! this parameter is vital to correct splitting of the tree.
:param current_depth: Keeping track of the current depth in the tree
:return: Returns the three different groups of distance and binary values.
"""
if
len
(
tree
)
<
num_features_per_node
:
...
...
@@ -69,9 +76,15 @@ def split_tree(tree, num_features_per_node=8, current_depth=0):
depth
+=
1
pow4
*=
4
child_size
=
(
len
(
tree
)
-
num_features_per_node
)
//
4
"""
Here we split the node features into the different classes of distances and binary values.
Pay close attention to this part if you modify any of the features in the tree observation.
"""
tree_data
=
tree
[:
4
].
tolist
()
distance_data
=
[
tree
[
4
]]
agent_data
=
tree
[
5
:
num_features_per_node
].
tolist
()
# Split each child of the current node and continue to next depth level
for
children
in
range
(
4
):
child_tree
=
tree
[(
num_features_per_node
+
children
*
child_size
):
(
num_features_per_node
+
(
children
+
1
)
*
child_size
)]
...
...
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