Skip to content

Commit

Permalink
Merge pull request #84 from allenai/advisor_into_master
Browse files Browse the repository at this point in the history
Running black, optimizing imports, and inelegant merging of engines (currently kept as separate files).
  • Loading branch information
Lucaweihs committed Jul 20, 2020
2 parents 16d6a99 + 365786c commit d1afa37
Show file tree
Hide file tree
Showing 82 changed files with 3,864 additions and 2,123 deletions.
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,16 @@ dmypy.json
*.pt

# Default output dir
experiment_output
experiment_output

# PDFs
*.pdf

# Tensorboard logs
events.out.tfevents.*

# TSV files
*.tsv

# tmp directory
tmp/
4 changes: 4 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ numpy-quaternion = "*"
pandas = "*"
seaborn = "*"
statsmodels = "*"
gym-minigrid = "*"
gin-config = "*"
babyai = {editable = true,git = "https://github.com/unnat/babyai.git",ref = "ff645fe00ea8412a29bd5e2d6f79ae1595d229a7"}
localreg = "*"

[requires]
python_version = "3.6"
15 changes: 7 additions & 8 deletions ddmain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Entry point to training/validating/testing for a user given experiment name"""
"""Entry point to training/validating/testing for a user given experiment
name."""

import argparse
import importlib
Expand All @@ -11,7 +12,7 @@

from onpolicy_sync.runner import OnPolicyRunner
from rl_base.experiment_config import ExperimentConfig
from utils.system import init_logging, LOGGER
from utils.system import get_logger


def _get_args():
Expand All @@ -31,8 +32,8 @@ def _get_args():
default="",
required=False,
help="Add an extra tag to the experiment when trying out new ideas (will be used"
"as a suffix of the experiment name). It also has to be provided when testing on"
"the trained model.",
"as a suffix of the experiment name). It also has to be provided when testing on"
"the trained model.",
)

parser.add_argument(
Expand Down Expand Up @@ -70,7 +71,7 @@ def _get_args():
action="store_true",
required=False,
help="for training, if checkpoint is specified, use it as model initialization and "
"restart training with current config",
"restart training with current config",
)
parser.set_defaults(restart=False)

Expand Down Expand Up @@ -152,11 +153,9 @@ def _load_config(args) -> Tuple[ExperimentConfig, Dict[str, Tuple[str, str]]]:


def main():
init_logging()

args = _get_args()

LOGGER.info("Running with args {}".format(args))
get_logger().info("Running with args {}".format(args))

ptitle("Master: {}".format("Training" if args.test_date is None else "Testing"))

Expand Down
2 changes: 1 addition & 1 deletion docs/overview/defining-a-new-task.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Finally, we need to define methods to determine the number of available tasks (p
```python

@property
def __len__(self) -> Union[int, float]:
def length(self) -> Union[int, float]:
return float("inf")

@property
Expand Down
4 changes: 2 additions & 2 deletions docs/overview/experiment.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ defined which task we wish to train our agent to complete. This is done by imple
```python
class ObjectNavThorPPOExperimentConfig(rl_base.experiment_config.ExperimentConfig):
...
@staticmethod
def make_sampler_fn(**kwargs) -> rl_base.task.TaskSampler:
@classmethod
def make_sampler_fn(cls, **kwargs) -> rl_base.task.TaskSampler:
return rl_ai2thor.object_nav.task_samplers.ObjectNavTaskSampler(**kwargs)
...
```
Expand Down
4 changes: 2 additions & 2 deletions experiments/object_nav_thor_a2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def create_model(cls, **kwargs) -> nn.Module:
object_type_embedding_dim=8,
)

@staticmethod
def make_sampler_fn(**kwargs) -> TaskSampler:
@classmethod
def make_sampler_fn(cls, **kwargs) -> TaskSampler:
return ObjectNavTaskSampler(**kwargs)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion experiments/object_nav_thor_dagger_ppo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
import torch.optim as optim
from torch.optim.lr_scheduler import LambdaLR

from .object_nav_thor_ppo import ObjectNavThorPPOExperimentConfig
from onpolicy_sync.losses import PPO
from onpolicy_sync.losses.imitation import Imitation
from onpolicy_sync.losses.ppo import PPOConfig
from rl_ai2thor.ai2thor_sensors import RGBSensorThor, GoalObjectTypeThorSensor
from rl_base.sensor import ExpertActionSensor
from utils.experiment_utils import LinearDecay, Builder, PipelineStage, TrainingPipeline
from .object_nav_thor_ppo import ObjectNavThorPPOExperimentConfig


class ObjectNavThorDAggerPPOExperimentConfig(ObjectNavThorPPOExperimentConfig):
Expand Down
5 changes: 2 additions & 3 deletions experiments/object_nav_thor_ppo.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from torch.optim.lr_scheduler import LambdaLR

from models.object_nav_models import ObjectNavBaselineActorCritic

from onpolicy_sync.losses import PPO
from onpolicy_sync.losses.ppo import PPOConfig
from rl_ai2thor.ai2thor_sensors import RGBSensorThor, GoalObjectTypeThorSensor
Expand Down Expand Up @@ -139,8 +138,8 @@ def create_model(cls, **kwargs) -> nn.Module:
object_type_embedding_dim=8,
)

@staticmethod
def make_sampler_fn(**kwargs) -> TaskSampler:
@classmethod
def make_sampler_fn(cls, **kwargs) -> TaskSampler:
return ObjectNavTaskSampler(**kwargs)

@staticmethod
Expand Down
10 changes: 5 additions & 5 deletions experiments/objectnav_habitat_base.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
from typing import Dict, Any, List, Optional
from abc import abstractmethod
from typing import Dict, Any, List, Optional

import gym
import habitat
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim.lr_scheduler import LambdaLR

import habitat
from onpolicy_sync.losses.ppo import PPOConfig
from models.point_nav_models import PointNavActorCriticResNet50GRU
from onpolicy_sync.losses import PPO
from onpolicy_sync.losses.ppo import PPOConfig
from rl_base.experiment_config import ExperimentConfig
from rl_base.preprocessor import ObservationSet
from rl_base.sensor import SensorSuite
from rl_base.task import TaskSampler
from rl_base.preprocessor import ObservationSet
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_task_samplers import ObjectNavTaskSampler
from rl_habitat.habitat_tasks import ObjectNavTask
from utils.experiment_utils import Builder, PipelineStage, TrainingPipeline, LinearDecay


Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import gym
import habitat
import torch.nn as nn
from torchvision import models

import habitat

from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig
from models.object_nav_models import ObjectNavResNetActorCritic
from rl_base.sensor import SensorSuite
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_preprocessors import ResnetPreProcessorHabitat
from rl_habitat.habitat_sensors import DepthSensorHabitat, TargetObjectSensorHabitat
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_utils import construct_env_configs
from rl_habitat.habitat_preprocessors import ResnetPreProcessorHabitat
from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig


class ObjectNavHabitatDepthDeterministicResNet50GRUPPOExperimentConfig(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import gym
import torch.nn as nn

import habitat
import torch.nn as nn

from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig
from models.object_nav_models import ObjectNavBaselineActorCritic
from rl_base.sensor import SensorSuite
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_sensors import DepthSensorHabitat, TargetObjectSensorHabitat
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_utils import construct_env_configs
from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig


class ObjectNavHabitatDebthDeterministicSimpleConvGRUPPOExperimentConfig(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import gym
import habitat
import torch.nn as nn
from torchvision import models

import habitat

from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig
from models.object_nav_models import ObjectNavResNetActorCritic
from rl_base.sensor import SensorSuite
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_preprocessors import ResnetPreProcessorHabitat
from rl_habitat.habitat_sensors import RGBSensorHabitat, TargetObjectSensorHabitat
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_utils import construct_env_configs
from rl_habitat.habitat_preprocessors import ResnetPreProcessorHabitat
from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig


class ObjectNavHabitatRGBDeterministicResNet50GRUPPOExperimentConfig(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import gym
import torch.nn as nn

import habitat
import torch.nn as nn

from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig
from models.object_nav_models import ObjectNavBaselineActorCritic
from rl_base.sensor import SensorSuite
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_sensors import RGBSensorHabitat, TargetObjectSensorHabitat
from rl_habitat.habitat_tasks import ObjectNavTask
from rl_habitat.habitat_utils import construct_env_configs
from experiments.objectnav_habitat_base import ObjectNavHabitatBaseExperimentConfig


class ObjectNavHabitatRGBDeterministicSimpleConvGRUPPOExperimentConfig(
Expand Down

0 comments on commit d1afa37

Please sign in to comment.