Giter Site home page Giter Site logo

Comments (8)

abhiskk avatar abhiskk commented on May 21, 2024 5

@takuma-ynd if you want to switch to loading these environments manually you can modify the logic here: https://github.com/facebookresearch/habitat-api/blob/master/habitat/core/env.py#L178-L184 . On a reset call the episode index is advanced and the reconfigure in line 185 then loads the house from new episode into the simulator.

I think you might have already identified this but stating it to be clear, it is important for training the PPO that the episodes are randomly sampled, but there is a trade-off here, if you randomly sample the episode it is likely that each successive episode will be in a different environment, this is not good in terms of speed as this would mean that there would be loading and dumping of graphical assets in the simulator which is usually a slow step, a way around this is if you shuffle the episodes such that consecutive shuffle_interval episodes happen inside the same house, in our experiments we used a shuffle_interval value of 500:

def shuffle_episodes(self, shuffle_interval):
    ranges = np.arange(0, len(self.episodes), shuffle_interval)
    np.random.shuffle(ranges)
    new_episodes = []
    for r in ranges:
        new_episodes += self.episodes[r:r + shuffle_interval]
    self.episodes = new_episodes

This method would be present inside the PointnavDatasetV1 class and the method would be called just after the dataset is created (after this line)

Ideally this method should have been part of the original codebase which was opensourced, if you do end up using this or any other modification of shuffling can you go ahead and open a PR for this.

Let me know if you have any other questions. Thanks 🙂

from habitat-lab.

smorad avatar smorad commented on May 21, 2024 2

Just to update this, there now appears to be a way to force a switch, present in the episode iterator's __next__ method

https://github.com/facebookresearch/habitat-api/blob/master/habitat/core/dataset.py#L391

from habitat-lab.

erikwijmans avatar erikwijmans commented on May 21, 2024 1

This is what initiates a scene switch: https://github.com/facebookresearch/habitat-api/blob/master/habitat/core/dataset.py#L249 -- the environment then just tells the simulator what scene to load for a given episode.

We currently don't have a way to force a scene switch with a method call.

from habitat-lab.

mathfac avatar mathfac commented on May 21, 2024

Hi @a7b23, that means that first scene that Simulator will load will be the one specified in the first episode of a dataset.
Regarding train.json all episodes are loaded from subfolder content that contains scene based episodes.

from habitat-lab.

mathfac avatar mathfac commented on May 21, 2024

Feel free to re-open the issue, if you still have questions.

from habitat-lab.

takuma-yoneda avatar takuma-yoneda commented on May 21, 2024

I understand that when we use train.json, all episodes are loaded from subfolder content, but how can we switch those loaded environments manually?

When I read train.ppo, I got confused because I couldn't find any code that explicitly switches environments.

In addition, I could not find anything for switching environments in Env class, either.

Could you clarify this point?
Thanks!

from habitat-lab.

yimengli46 avatar yimengli46 commented on May 21, 2024

So how to switch scene exactly? I'm still confused after reading the response.

from habitat-lab.

rpartsey avatar rpartsey commented on May 21, 2024

The example how the scene can be switched in the PointNav task (you may do the scene switch for the other tasks by following the same logic):

from habitat.datasets.pointnav.pointnav_generator import generate_pointnav_episode
from habitat.tasks.nav.nav import merge_sim_episode_config


# 1. switch the scene to new_scene
sim_config.defrost()
sim_config.SCENE = new_scene
sim_config.freeze()
sim.reconfigure(sim_config)

# 2. generate the episode for new_scene
episode_gen = generate_pointnav_episode(
    sim=sim,
    is_gen_shortest_path=False
)
new_episode = next(episode_gen)

sim_config.defrost()
sim_config = merge_sim_episode_config(
    sim_config,
    new_episode
)
sim_config.freeze()
sim.reconfigure(sim_config)

# 3. reset the sim
obs = sim.reset()

# 4. do what you want

For more detailed implementation you may refer to this code.

Feel free to re-open the issue, if you still have questions.

from habitat-lab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.