Stack Scans to See Motion
~12 mincode completion
Implement stack_scans(history, offsets) returning the flat 1D observation.
Examples
Three scans, newest first in the observation
- Input
- stack_scans([[1, 2], [3, 4], [5, 6]], [0, 1, 2])
- Output
- [5, 6, 3, 4, 1, 2]
Offsets need not be consecutive
- Input
- stack_scans([[1, 2], [3, 4], [5, 6]], [0, 2])
- Output
- [5, 6, 1, 2]
At the start of an episode the history is short and clamps
- Input
- stack_scans([[1, 2]], [0, 1, 2])
- Output
- [1, 2, 1, 2, 1, 2]
Hints
Hint 1
Reshape so the two arrays broadcast against each other.
Hint 2
Watch for this: stacked oldest first so the current scan was not at the front.
Requirements
history: (T, R) scans in time order, most recent lastoffsets: (K,) steps back from now; 0 is the current scan
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
EasyEasyEasyEasy
Running Observation Normalisation
Reinforcement Learning: Rewards, Senses and PPO · ~14 min
Explained Variance of the Value Head
Reinforcement Learning: Rewards, Senses and PPO · ~12 min
When Dying Early Pays
Reinforcement Learning: Rewards, Senses and PPO · ~14 min
The TD Error
Reinforcement Learning: Rewards, Senses and PPO · ~14 min
Python
import numpy as np
def stack_scans(history, offsets):
"""
Concatenate several past lidar scans into one observation.
Args:
history: (T, R) scans in time order, most recent last
offsets: (K,) steps back from now; 0 is the current scan
Returns:
(K * R,) array, the scans concatenated in offset order.
Offsets older than the buffer clamp to the oldest scan.
"""
# YOUR CODE HERE
pass