class
EpisodeIteratorEpisode Iterator class that gives options for how a list of episodes should be iterated.
Some of those options are desirable for the internal simulator to get higher performance. More context: simulator suffers overhead when switching between scenes, therefore episodes of the same scene should be loaded consecutively. However, if too many consecutive episodes from same scene are feed into RL model, the model will risk to overfit that scene. Therefore it’s better to load same scene consecutively and switch once a number threshold is reached.
Currently supports the following features:
- Cycling:
- when all episodes are iterated, cycle back to start instead of throwing StopIteration.
- Cycling with shuffle:
- when cycling back, shuffle episodes groups grouped by scene.
- Group by scene:
- episodes of same scene will be grouped and loaded consecutively.
- Set max scene repeat:
- set a number threshold on how many episodes from the same scene can be loaded consecutively.
- Sample episodes:
- sample the specified number of episodes.
Methods
- def _forced_scene_switch(self) -> None
- Internal method to switch the scene. Moves remaining episodes from current scene to the end and switch to next scene episodes.
- def _group_scenes(self, episodes: typing.Union[typing.Sequence[Episode], typing.List[Episode], numpy.ndarray]) -> typing.List[T]
- Internal method that groups episodes by scene Groups will be ordered by the order the first episode of a given scene is in the list of episodes
- def _shuffle(self) -> None
- Internal method that shuffles the remaining episodes. If self.group_by_scene is true, then shuffle groups of scenes.
- def step_taken(self) -> None
Special methods
- def __class_getitem__(...)
- Represent a PEP 585 generic type
- def __init__(self, episodes: typing.Sequence[T], cycle: bool = True, shuffle: bool = False, group_by_scene: bool = True, max_scene_repeat_episodes: int = -1, max_scene_repeat_steps: int = -1, num_episode_sample: int = -1, step_repetition_range: float = 0.2, seed: typing.Optional[int] = None) -> None
- def __iter__(self) -> EpisodeIterator
- def __next__(self) -> Episode
- The main logic for handling how episodes will be iterated.
- def __subclasshook__(C)
Method documentation
def habitat. core. dataset. EpisodeIterator. _group_scenes(self,
episodes: typing.Union[typing.Sequence[Episode], typing.List[Episode], numpy.ndarray]) -> typing.List[T]
Internal method that groups episodes by scene Groups will be ordered by the order the first episode of a given scene is in the list of episodes
So if the episodes list shuffled before calling this method, the scenes will be in a random order
def habitat. core. dataset. EpisodeIterator. __class_getitem__(...) classmethod
Represent a PEP 585 generic type
E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
def habitat. core. dataset. EpisodeIterator. __init__(self,
episodes: typing.Sequence[T],
cycle: bool = True,
shuffle: bool = False,
group_by_scene: bool = True,
max_scene_repeat_episodes: int = -1,
max_scene_repeat_steps: int = -1,
num_episode_sample: int = -1,
step_repetition_range: float = 0.2,
seed: typing.Optional[int] = None) -> None
Parameters | |
---|---|
episodes | list of episodes. |
cycle | if True , cycle back to first episodes when
StopIteration. |
shuffle | if True , shuffle scene groups when cycle. No
effect if cycle is set to False . Will shuffle grouped scenes
if group_by_scene is True . |
group_by_scene | if True , group episodes from same scene. |
max_scene_repeat_episodes | threshold of how many episodes from the same
scene can be loaded consecutively. -1 for no limit |
max_scene_repeat_steps | threshold of how many steps from the same
scene can be taken consecutively. -1 for no limit |
num_episode_sample | number of episodes to be sampled. -1
for no sampling. |
step_repetition_range | The maximum number of steps within each scene is uniformly drawn from [1 - step_repeat_range, 1 + step_repeat_range] * max_scene_repeat_steps on each scene switch. This stops all workers from swapping scenes at the same time |
seed |