Showing preview only (2,166K chars total). Download the full file or copy to clipboard to get everything.
Repository: allenai/allenact
Branch: main
Commit: d055fc9d4533
Files: 402
Total size: 2.0 MB
Directory structure:
gitextract_rp45h8jw/
├── .VERSION
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ ├── feature_request.md
│ │ └── support_request.md
│ └── workflows/
│ ├── black.yml
│ ├── codeql.yml
│ ├── publish.yml
│ └── pytest.yml
├── .gitignore
├── .gitmodules
├── .pre-commit-config.yaml
├── CNAME
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── ROADMAP.md
├── allenact/
│ ├── __init__.py
│ ├── _constants.py
│ ├── algorithms/
│ │ ├── __init__.py
│ │ ├── offpolicy_sync/
│ │ │ ├── __init__.py
│ │ │ └── losses/
│ │ │ ├── __init__.py
│ │ │ └── abstract_offpolicy_loss.py
│ │ └── onpolicy_sync/
│ │ ├── __init__.py
│ │ ├── engine.py
│ │ ├── losses/
│ │ │ ├── __init__.py
│ │ │ ├── a2cacktr.py
│ │ │ ├── abstract_loss.py
│ │ │ ├── grouped_action_imitation.py
│ │ │ ├── imitation.py
│ │ │ └── ppo.py
│ │ ├── misc.py
│ │ ├── policy.py
│ │ ├── runner.py
│ │ ├── storage.py
│ │ └── vector_sampled_tasks.py
│ ├── base_abstractions/
│ │ ├── __init__.py
│ │ ├── callbacks.py
│ │ ├── distributions.py
│ │ ├── experiment_config.py
│ │ ├── misc.py
│ │ ├── preprocessor.py
│ │ ├── sensor.py
│ │ └── task.py
│ ├── embodiedai/
│ │ ├── __init__.py
│ │ ├── aux_losses/
│ │ │ ├── __init__.py
│ │ │ └── losses.py
│ │ ├── mapping/
│ │ │ ├── __init__.py
│ │ │ ├── mapping_losses.py
│ │ │ ├── mapping_models/
│ │ │ │ ├── __init__.py
│ │ │ │ └── active_neural_slam.py
│ │ │ └── mapping_utils/
│ │ │ ├── __init__.py
│ │ │ ├── map_builders.py
│ │ │ └── point_cloud_utils.py
│ │ ├── models/
│ │ │ ├── __init__.py
│ │ │ ├── aux_models.py
│ │ │ ├── basic_models.py
│ │ │ ├── fusion_models.py
│ │ │ ├── resnet.py
│ │ │ └── visual_nav_models.py
│ │ ├── preprocessors/
│ │ │ ├── __init__.py
│ │ │ └── resnet.py
│ │ ├── sensors/
│ │ │ ├── __init__.py
│ │ │ └── vision_sensors.py
│ │ └── storage/
│ │ ├── __init__.py
│ │ └── vdr_storage.py
│ ├── main.py
│ ├── setup.py
│ └── utils/
│ ├── __init__.py
│ ├── cache_utils.py
│ ├── cacheless_frcnn.py
│ ├── experiment_utils.py
│ ├── inference.py
│ ├── misc_utils.py
│ ├── model_utils.py
│ ├── multi_agent_viz_utils.py
│ ├── spaces_utils.py
│ ├── system.py
│ ├── tensor_utils.py
│ └── viz_utils.py
├── allenact_plugins/
│ ├── __init__.py
│ ├── babyai_plugin/
│ │ ├── __init__.py
│ │ ├── babyai_constants.py
│ │ ├── babyai_models.py
│ │ ├── babyai_tasks.py
│ │ ├── configs/
│ │ │ └── __init__.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── download_babyai_expert_demos.py
│ │ ├── get_instr_length_percentiles.py
│ │ └── truncate_expert_demos.py
│ ├── clip_plugin/
│ │ ├── __init__.py
│ │ ├── clip_preprocessors.py
│ │ ├── extra_environment.yml
│ │ └── extra_requirements.txt
│ ├── gym_plugin/
│ │ ├── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── gym_distributions.py
│ │ ├── gym_environment.py
│ │ ├── gym_models.py
│ │ ├── gym_sensors.py
│ │ └── gym_tasks.py
│ ├── habitat_plugin/
│ │ ├── __init__.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_environment_headless.yml
│ │ ├── extra_requirements.txt
│ │ ├── habitat_constants.py
│ │ ├── habitat_environment.py
│ │ ├── habitat_preprocessors.py
│ │ ├── habitat_sensors.py
│ │ ├── habitat_task_samplers.py
│ │ ├── habitat_tasks.py
│ │ ├── habitat_utils.py
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── agent_demo.py
│ │ └── make_map.py
│ ├── ithor_plugin/
│ │ ├── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── ithor_constants.py
│ │ ├── ithor_environment.py
│ │ ├── ithor_sensors.py
│ │ ├── ithor_task_samplers.py
│ │ ├── ithor_tasks.py
│ │ ├── ithor_util.py
│ │ ├── ithor_viz.py
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── make_objectnav_debug_dataset.py
│ │ └── make_pointnav_debug_dataset.py
│ ├── lighthouse_plugin/
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ └── __init__.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── lighthouse_environment.py
│ │ ├── lighthouse_models.py
│ │ ├── lighthouse_sensors.py
│ │ ├── lighthouse_tasks.py
│ │ ├── lighthouse_util.py
│ │ └── scripts/
│ │ └── __init__.py
│ ├── manipulathor_plugin/
│ │ ├── __init__.py
│ │ ├── arm_calculation_utils.py
│ │ ├── armpointnav_constants.py
│ │ ├── manipulathor_constants.py
│ │ ├── manipulathor_environment.py
│ │ ├── manipulathor_sensors.py
│ │ ├── manipulathor_task_samplers.py
│ │ ├── manipulathor_tasks.py
│ │ ├── manipulathor_utils.py
│ │ └── manipulathor_viz.py
│ ├── minigrid_plugin/
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ ├── __init__.py
│ │ │ └── minigrid_nomemory.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── minigrid_environments.py
│ │ ├── minigrid_models.py
│ │ ├── minigrid_offpolicy.py
│ │ ├── minigrid_sensors.py
│ │ ├── minigrid_tasks.py
│ │ └── scripts/
│ │ └── __init__.py
│ ├── navigation_plugin/
│ │ ├── __init__.py
│ │ ├── objectnav/
│ │ │ ├── __init__.py
│ │ │ └── models.py
│ │ └── pointnav/
│ │ ├── __init__.py
│ │ └── models.py
│ ├── robothor_plugin/
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── robothor_constants.py
│ │ ├── robothor_distributions.py
│ │ ├── robothor_environment.py
│ │ ├── robothor_models.py
│ │ ├── robothor_preprocessors.py
│ │ ├── robothor_sensors.py
│ │ ├── robothor_task_samplers.py
│ │ ├── robothor_tasks.py
│ │ ├── robothor_viz.py
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── make_objectnav_debug_dataset.py
│ │ └── make_pointnav_debug_dataset.py
│ └── setup.py
├── conda/
│ ├── environment-10.1.yml
│ ├── environment-10.2.yml
│ ├── environment-11.1.yml
│ ├── environment-9.2.yml
│ ├── environment-base.yml
│ ├── environment-cpu.yml
│ └── environment-dev.yml
├── constants.py
├── datasets/
│ ├── .gitignore
│ ├── .habitat_datasets_download_info.json
│ ├── .habitat_downloader_helper.py
│ ├── download_habitat_datasets.sh
│ └── download_navigation_datasets.sh
├── dev_requirements.txt
├── docs/
│ ├── .gitignore
│ ├── CNAME
│ ├── FAQ.md
│ ├── css/
│ │ └── extra.css
│ ├── getting_started/
│ │ ├── abstractions.md
│ │ ├── running-your-first-experiment.md
│ │ └── structure.md
│ ├── howtos/
│ │ ├── changing-rewards-and-losses.md
│ │ ├── defining-a-new-model.md
│ │ ├── defining-a-new-task.md
│ │ ├── defining-a-new-training-pipeline.md
│ │ ├── defining-an-experiment.md
│ │ ├── running-a-multi-agent-experiment.md
│ │ └── visualizing-results.md
│ ├── installation/
│ │ ├── download-datasets.md
│ │ ├── installation-allenact.md
│ │ └── installation-framework.md
│ ├── javascripts/
│ │ └── extra.js
│ ├── notebooks/
│ │ └── firstbook.md
│ ├── projects/
│ │ ├── advisor_2020/
│ │ │ └── README.md
│ │ ├── babyai_baselines/
│ │ │ └── README.md
│ │ ├── gym_baselines/
│ │ │ └── README.md
│ │ ├── objectnav_baselines/
│ │ │ └── README.md
│ │ ├── pointnav_baselines/
│ │ │ └── README.md
│ │ └── two_body_problem_2019/
│ │ └── README.md
│ └── tutorials/
│ ├── distributed-objectnav-tutorial.md
│ ├── gym-mujoco-tutorial.md
│ ├── gym-tutorial.md
│ ├── index.md
│ ├── minigrid-tutorial.md
│ ├── offpolicy-tutorial.md
│ ├── running-inference-on-a-pretrained-model.md
│ ├── training-a-pointnav-model.md
│ ├── training-pipelines.md
│ └── transfering-to-a-different-environment-framework.md
├── main.py
├── mkdocs.yml
├── mypy.ini
├── overrides/
│ └── main.html
├── pretrained_model_ckpts/
│ ├── .gitignore
│ └── download_navigation_model_ckpts.sh
├── projects/
│ ├── __init__.py
│ ├── babyai_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ └── experiments/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── go_to_local/
│ │ │ ├── __init__.py
│ │ │ ├── a2c.py
│ │ │ ├── base.py
│ │ │ ├── bc.py
│ │ │ ├── bc_teacher_forcing.py
│ │ │ ├── dagger.py
│ │ │ ├── distributed_bc_offpolicy.py
│ │ │ ├── distributed_bc_teacher_forcing.py
│ │ │ └── ppo.py
│ │ └── go_to_obj/
│ │ ├── __init__.py
│ │ ├── a2c.py
│ │ ├── base.py
│ │ ├── bc.py
│ │ ├── bc_teacher_forcing.py
│ │ ├── dagger.py
│ │ └── ppo.py
│ ├── gym_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── gym_base.py
│ │ │ ├── gym_humanoid_base.py
│ │ │ ├── gym_humanoid_ddppo.py
│ │ │ ├── gym_mujoco_base.py
│ │ │ ├── gym_mujoco_ddppo.py
│ │ │ └── mujoco/
│ │ │ ├── __init__.py
│ │ │ ├── gym_mujoco_ant_ddppo.py
│ │ │ ├── gym_mujoco_halfcheetah_ddppo.py
│ │ │ ├── gym_mujoco_hopper_ddppo.py
│ │ │ ├── gym_mujoco_humanoid_ddppo.py
│ │ │ ├── gym_mujoco_inverteddoublependulum_ddppo.py
│ │ │ ├── gym_mujoco_invertedpendulum_ddppo.py
│ │ │ ├── gym_mujoco_reacher_ddppo.py
│ │ │ ├── gym_mujoco_swimmer_ddppo.py
│ │ │ └── gym_mujoco_walker2d_ddppo.py
│ │ └── models/
│ │ ├── __init__.py
│ │ └── gym_models.py
│ ├── manipulathor_baselines/
│ │ ├── __init__.py
│ │ └── armpointnav_baselines/
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── armpointnav_base.py
│ │ │ ├── armpointnav_mixin_ddppo.py
│ │ │ ├── armpointnav_mixin_simplegru.py
│ │ │ ├── armpointnav_thor_base.py
│ │ │ └── ithor/
│ │ │ ├── __init__.py
│ │ │ ├── armpointnav_depth.py
│ │ │ ├── armpointnav_disjoint_depth.py
│ │ │ ├── armpointnav_ithor_base.py
│ │ │ ├── armpointnav_no_vision.py
│ │ │ ├── armpointnav_rgb.py
│ │ │ └── armpointnav_rgbdepth.py
│ │ └── models/
│ │ ├── __init__.py
│ │ ├── arm_pointnav_models.py
│ │ ├── base_models.py
│ │ ├── disjoint_arm_pointnav_models.py
│ │ └── manipulathor_net_utils.py
│ ├── objectnav_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── clip/
│ │ │ │ ├── __init__.py
│ │ │ │ └── mixins.py
│ │ │ ├── habitat/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── clip/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── objectnav_habitat_rgb_clipresnet50gru_ddppo.py
│ │ │ │ │ └── objectnav_habitat_rgb_clipresnet50gru_ddppo_increasingrollouts.py
│ │ │ │ └── objectnav_habitat_base.py
│ │ │ ├── ithor/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── objectnav_ithor_base.py
│ │ │ │ ├── objectnav_ithor_depth_resnet18gru_ddppo.py
│ │ │ │ ├── objectnav_ithor_rgb_resnet18gru_ddppo.py
│ │ │ │ └── objectnav_ithor_rgbd_resnet18gru_ddppo.py
│ │ │ ├── objectnav_base.py
│ │ │ ├── objectnav_thor_base.py
│ │ │ └── robothor/
│ │ │ ├── __init__.py
│ │ │ ├── beta/
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ ├── objectnav_robothor_rgb_resnetgru_ddppo_and_gbc.py
│ │ │ │ └── objectnav_robothor_rgb_unfrozenresnet18gru_vdr_ddppo.py
│ │ │ ├── clip/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── objectnav_robothor_rgb_clipresnet50gru_ddppo.py
│ │ │ │ └── objectnav_robothor_rgb_clipresnet50x16gru_ddppo.py
│ │ │ ├── objectnav_robothor_base.py
│ │ │ ├── objectnav_robothor_depth_resnet18gru_ddppo.py
│ │ │ ├── objectnav_robothor_rgb_resnet18gru_dagger.py
│ │ │ ├── objectnav_robothor_rgb_resnet18gru_ddppo.py
│ │ │ ├── objectnav_robothor_rgb_resnet50gru_ddppo.py
│ │ │ ├── objectnav_robothor_rgb_unfrozenresnet18gru_ddppo.py
│ │ │ └── objectnav_robothor_rgbd_resnet18gru_ddppo.py
│ │ └── mixins.py
│ ├── pointnav_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── habitat/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── clip/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── pointnav_habitat_rgb_clipresnet50gru_ddppo.py
│ │ │ │ ├── pointnav_habitat_base.py
│ │ │ │ ├── pointnav_habitat_depth_simpleconvgru_ddppo.py
│ │ │ │ ├── pointnav_habitat_rgb_simpleconvgru_ddppo.py
│ │ │ │ └── pointnav_habitat_rgbd_simpleconvgru_ddppo.py
│ │ │ ├── ithor/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── pointnav_ithor_base.py
│ │ │ │ ├── pointnav_ithor_depth_simpleconvgru_ddppo.py
│ │ │ │ ├── pointnav_ithor_rgb_simpleconvgru_ddppo.py
│ │ │ │ └── pointnav_ithor_rgbd_simpleconvgru_ddppo.py
│ │ │ ├── pointnav_base.py
│ │ │ ├── pointnav_thor_base.py
│ │ │ └── robothor/
│ │ │ ├── __init__.py
│ │ │ ├── pointnav_robothor_base.py
│ │ │ ├── pointnav_robothor_depth_simpleconvgru_ddppo.py
│ │ │ ├── pointnav_robothor_rgb_simpleconvgru_ddppo.py
│ │ │ └── pointnav_robothor_rgbd_simpleconvgru_ddppo.py
│ │ └── mixins.py
│ └── tutorials/
│ ├── __init__.py
│ ├── distributed_objectnav_tutorial.py
│ ├── gym_mujoco_tutorial.py
│ ├── gym_tutorial.py
│ ├── minigrid_offpolicy_tutorial.py
│ ├── minigrid_tutorial.py
│ ├── minigrid_tutorial_conds.py
│ ├── navtopartner_robothor_rgb_ppo.py
│ ├── object_nav_ithor_dagger_then_ppo_one_object.py
│ ├── object_nav_ithor_dagger_then_ppo_one_object_viz.py
│ ├── object_nav_ithor_ppo_one_object.py
│ ├── pointnav_habitat_rgb_ddppo.py
│ ├── pointnav_ithor_rgb_ddppo.py
│ ├── running_inference_tutorial.py
│ └── training_a_pointnav_model.py
├── requirements.txt
├── scripts/
│ ├── auto_format.sh
│ ├── build_docs.py
│ ├── build_docs.sh
│ ├── dcommand.py
│ ├── dconfig.py
│ ├── dkill.py
│ ├── dmain.py
│ ├── literate.py
│ ├── release.py
│ ├── run_tests.sh
│ └── startx.py
└── tests/
├── .gitignore
├── __init__.py
├── hierarchical_policies/
│ ├── __init__.py
│ └── test_minigrid_conditional.py
├── manipulathor_plugin/
│ ├── __init__.py
│ └── test_utils.py
├── mapping/
│ ├── __init__.py
│ └── test_ai2thor_mapping.py
├── multiprocessing/
│ ├── __init__.py
│ └── test_frozen_attribs.py
├── sync_algs_cpu/
│ ├── __init__.py
│ └── test_to_to_obj_trains.py
├── utils/
│ ├── __init__.py
│ ├── test_inference_agent.py
│ └── test_spaces.py
└── vision/
├── __init__.py
└── test_pillow_rescaling.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .VERSION
================================================
0.5.5a
================================================
FILE: .github/ISSUE_TEMPLATE/bug_report.md
================================================
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''
---
## Problem
A clear and concise description of what the bug is.
## Steps to reproduce
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Expected behavior
A clear and concise description of what you expected to happen.
## Screenshots
If applicable, add screenshots to help explain your problem.
## Desktop
Please add the following information:
- OS: [e.g. Ubuntu 16.04.5]
- AllenAct Version: [e.g. current HEAD of master or v0.1.0]
## Additional context
Add any other context about the problem here.
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an enhancement or a new feature
title: ''
labels: enhancement
assignees: ''
---
## Problem
Is your feature request related to a problem? Please provide a clear and concise description of what the problem is:
E.g. I would really like to have better support for my favorite environment X.
## Desired solution
A clear and concise description of what you want to happen.
## Alternative solutions
A description of any alternative solutions or features you've considered.
## Additional context
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/ISSUE_TEMPLATE/support_request.md
================================================
---
name: Support request
about: Request support regarding AllenAct
title: ''
labels: ''
assignees: ''
---
## Problem / Question
What do you need help with? E.g. "I'm having trouble running model X" or "when I run command Y I get error Z."
## Additional context
_(Optional)_ - To provide support it's helpful to have as many details as possible, add additional context here.
================================================
FILE: .github/workflows/black.yml
================================================
name: Lint
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
================================================
FILE: .github/workflows/codeql.yml
================================================
name: "CodeQL"
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: "13 6 * * 4"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ python ]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
- name: Autobuild
uses: github/codeql-action/autobuild@v2
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{ matrix.language }}"
================================================
FILE: .github/workflows/publish.yml
================================================
# This workflow will upload the allenact and allenact_plugins packages using Twine (after manually triggering it)
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Publish PYPI Packages
on:
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools twine
- name: Build and publish
env:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python scripts/release.py
twine upload -u __token__ dist/*
================================================
FILE: .github/workflows/pytest.yml
================================================
name: PyTest
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
steps:
- uses: actions/checkout@v2
- uses: ouzi-dev/commit-status-updater@v1.1.0 # Updates the commit status badge to pending
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install pytest wandb
python -m pip install --editable="./allenact"
python -m pip install --editable="./allenact_plugins[all]"
python -m pip install -e "git+https://github.com/Lucaweihs/babyai.git@0b450eeb3a2dc7116c67900d51391986bdbb84cd#egg=babyai"
python -m pip install compress_pickle # Needed for some mapping tests
pip list
- name: Test with pytest
run: |
pytest --capture=tee-sys tests
- if: always() # Updates the commit status badge to the result of running the tests above
uses: ouzi-dev/commit-status-updater@v1.1.0
with:
status: "${{ job.status }}"
================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
docs/build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pycharm
.idea/
# pytorch
*.pt
# Default output dir
experiment_output
*_out
# PDFs
*.pdf
# PNGs
*.png
# Tensorboard logs
events.out.tfevents.*
# TSV files
*.tsv
# tmp directory
tmp/
# Pickle files
*.pkl
*.pkl.gz
# Zip files
*.zip
# VSCode
.vscode/
# MacOS
.DS_Store
# Docs
docs/index.md
docs/CONTRIBUTING.md
docs/LICENSE.md
# Metrics
metrics__*.json
# Robothor
allenact_plugins/robothor_plugin/data/*
# ithor
allenact_plugins/ithor_plugin/data/*
# Habitat
external_projects/habitat-lab
# Local pip installations
src
.pip_src
# Files created when running training
**/used_configs
*.patch
# Package building
*.egg_info
*.egg-info
# Additional allenact-specific locks and hidden files
*.allenact_last_start_time_string
*.allenact_start_time_string.lock
*.lock
rsync-*
================================================
FILE: .gitmodules
================================================
[submodule "projects/ithor_rearrangement"]
path = projects/ithor_rearrangement
url = https://github.com/allenai/ai2thor-rearrangement.git
branch = active_neural_slam
================================================
FILE: .pre-commit-config.yaml
================================================
repos:
- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
language_version: python3.7
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.761' # Use the sha / tag you want to point at
hooks:
- id: mypy
args: [--follow-imports=skip]
================================================
FILE: CNAME
================================================
www.allenact.org
================================================
FILE: CONTRIBUTING.md
================================================
# Contributing
We welcome contributions from the greater community. If you would like to make such a contributions we recommend first submitting an [issue](https://github.com/allenai/allenact/issues) describing your proposed improvement.
Doing so can ensure we can validate your suggestions before you spend a great deal of time
upon them. Improvements and bug fixes should be made via a pull request
from your fork of the repository at [https://github.com/allenai/allenact](https://github.com/allenai/allenact).
All code in pull requests should adhere to the following guidelines.
## Found a bug or want to suggest an enhancement?
Please submit an [issue](https://github.com/allenai/allenact/issues) in which you note the steps
to reproduce the bug or in which you detail the enhancement.
## Making a pull request?
When making a pull request we require that any code respects several guidelines detailed below.
### Auto-formatting
All python code in this repository should be formatted using [black](https://black.readthedocs.io/en/stable/).
To use `black` auto-formatting across all files, simply run
```bash
bash scripts/auto_format.sh
```
which will run `black` auto-formatting as well as [docformatter](https://pypi.org/project/docformatter/) (used
to auto-format documentation strings).
### Type-checking
Our code makes liberal use of type hints. If you have not had experience with type hinting in python we recommend
reading the [documentation](https://docs.python.org/3/library/typing.html) of the `typing` python module or the
simplified introduction to type hints found [here](https://www.python.org/dev/peps/pep-0483/). All methods should
have typed arguments and output. Furthermore we use [mypy](https://mypy.readthedocs.io/en/stable/) to perform
basic static type checking. Before making a pull request, there should be no warnings or errors when running
```bash
dmypy run -- --follow-imports=skip .
```
Explicitly ignoring type checking (for instance using `# type: ignore`) should be only be done when it would otherwise
be an extensive burden.
<!-- TODO: This should be updated given how we're changing depdencies in AllenAct.
### Updating, adding, or removing packages?
If you are updating, adding, or removing packages please run:
```bash
pipenv-setup sync --pipfile # Syncs packages to setup.py
pip freeze > requirements.txt # Syncs packages to requirements.py
```
before submitting a pull request. If you are not using `pipenv`, you are still
required to update the file `Pipfile` with newly installed or modified packages. Moreover
you must manually update the `install_requires` field of the `setup.py` file.
-->
### Setting up pre-commit hooks (optional)
Pre-commit hooks check that, when you attempt to commit changes, your code adheres a number of
formatting and type-checking guidelines. Pull requests containing code not adhering to these
guidelines will not be accepted and thus we recommend installing these pre-commit hooks. Assuming you have
installed all of the project requirements, you can install our recommended
pre-commit hooks by running (from this project's root directory)
```bash
pre-commit install
```
After running the above, each time you run `git commit ...` a set of pre-commit checks will
be run.
================================================
FILE: LICENSE
================================================
MIT License
Original work Copyright (c) 2017 Ilya Kostrikov
Original work Copyright (c) Facebook, Inc. and its affiliates.
Modified work Copyright (c) 2020 Allen Institute for Artificial Intelligence
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
<div align="center">
<img src="docs/img/AllenAct.svg" width="350" />
<br>
<i><h3>An open source framework for research in Embodied AI</h3></i>
</p>
<hr/>
</div>
[](./LICENSE)
[](https://allenact.org)
[](https://github.com/allenai/allenact/releases/latest)
[](https://www.python.org/downloads/release/python-360/)
[](https://lgtm.com/projects/g/allenai/allenact/context:python)
[](https://github.com/psf/black)
**AllenAct** is a modular and flexible learning framework designed with a focus on the unique requirements of Embodied-AI research. It provides first-class support for a growing collection of embodied environments, tasks and algorithms, provides reproductions of state-of-the-art models and includes extensive documentation, tutorials, start-up code, and pre-trained models.
AllenAct is built and backed by the [Allen Institute for AI (AI2)](https://allenai.org/). AI2 is a non-profit institute with the mission to contribute to humanity through high-impact AI research and engineering.
## Quick Links
- [Website & Docs](https://www.allenact.org/)
- [Github](https://github.com/allenai/allenact)
- [Install](https://www.allenact.org/installation/installation-allenact/)
- [Tutorials](https://www.allenact.org/tutorials/)
- [AllenAct Paper](https://arxiv.org/abs/2008.12760)
- [Citation](#citation)
## Features & Highlights
* _Support for multiple environments_: Support for the [iTHOR](https://ai2thor.allenai.org/ithor/), [RoboTHOR](https://ai2thor.allenai.org/robothor/) and [Habitat](https://aihabitat.org/) embodied environments as well as for grid-worlds including [MiniGrid](https://github.com/maximecb/gym-minigrid).
* _Task Abstraction_: Tasks and environments are decoupled in AllenAct, enabling researchers to easily implement a large variety of tasks in the same environment.
* _Algorithms_: Support for a variety of on-policy algorithms including [PPO](https://arxiv.org/pdf/1707.06347.pdf), [DD-PPO](https://arxiv.org/pdf/1911.00357.pdf), [A2C](https://arxiv.org/pdf/1611.05763.pdf), Imitation Learning and [DAgger](https://www.ri.cmu.edu/pub_files/2011/4/Ross-AISTATS11-NoRegret.pdf) as well as offline training such as offline IL.
* _Sequential Algorithms_: It is trivial to experiment with different sequences of training routines, which are often the key to successful policies.
* _Simultaneous Losses_: Easily combine various losses while training models (e.g. use an external self-supervised loss while optimizing a PPO loss).
* _Multi-agent support_: Support for multi-agent algorithms and tasks.
* _Visualizations_: Out of the box support to easily visualize first and third person views for agents as well as intermediate model tensors, integrated into Tensorboard.
* _Pre-trained models_: Code and models for a number of standard Embodied AI tasks.
* _Tutorials_: Start-up code and extensive tutorials to help ramp up to Embodied AI.
* _First-class PyTorch support_: One of the few RL frameworks to target PyTorch.
* _Arbitrary action spaces_: Supporting both discrete and continuous actions.
|Environments|Tasks|Algorithms|
|------------|-----|----------|
|[iTHOR](https://ai2thor.allenai.org/ithor/), [RoboTHOR](https://ai2thor.allenai.org/robothor/), [Habitat](https://aihabitat.org/), [MiniGrid](https://github.com/maximecb/gym-minigrid), [OpenAI Gym](https://gym.openai.com/)|[PointNav](https://arxiv.org/pdf/1807.06757.pdf), [ObjectNav](https://arxiv.org/pdf/2006.13171.pdf), [MiniGrid tasks](https://github.com/maximecb/gym-minigrid), [Gym Box2D tasks](https://gym.openai.com/envs/#box2d)|[A2C](https://arxiv.org/pdf/1611.05763.pdf), [PPO](https://arxiv.org/pdf/1707.06347.pdf), [DD-PPO](https://arxiv.org/pdf/1911.00357.pdf), [DAgger](https://www.ri.cmu.edu/pub_files/2011/4/Ross-AISTATS11-NoRegret.pdf), Off-policy Imitation|
## Contributions
We welcome contributions from the greater community. If you would like to make such a contributions we recommend first submitting an [issue](https://github.com/allenai/allenact/issues) describing your proposed improvement. Doing so can ensure we can validate your suggestions before you spend a great deal of time upon them. Improvements and bug fixes should be made via a pull request from your fork of the repository at [https://github.com/allenai/allenact](https://github.com/allenai/allenact).
All code in this repository is subject to formatting, documentation, and type-annotation guidelines. For more details, please see the our [contribution guidelines](CONTRIBUTING.md).
## Acknowledgments
This work builds upon the [pytorch-a2c-ppo-acktr](https://github.com/ikostrikov/pytorch-a2c-ppo-acktr-gail) library of Ilya Kostrikov and uses some data structures from FAIR's [habitat-lab](https://github.com/facebookresearch/habitat-lab). We would like to thank Dustin Schwenk for his help for the public release of the framework.
## License
AllenAct is MIT licensed, as found in the [LICENSE](LICENSE) file.
## Team
AllenAct is an open-source project built by members of the PRIOR research group at the Allen Institute for Artificial Intelligence (AI2).
<div align="left">
<a href="//prior.allenai.org/" target="_blank">
<img src="docs/img/ai2-prior.svg" width="400">
</a>
<br>
</div>
## Citation
If you use this work, please cite our [paper](https://arxiv.org/abs/2008.12760):
```bibtex
@article{AllenAct,
author = {Luca Weihs and Jordi Salvador and Klemen Kotar and Unnat Jain and Kuo-Hao Zeng and Roozbeh Mottaghi and Aniruddha Kembhavi},
title = {AllenAct: A Framework for Embodied AI Research},
year = {2020},
journal = {arXiv preprint arXiv:2008.12760},
}
```
================================================
FILE: ROADMAP.md
================================================
# Roadmap
Here we track new features/support to be added in the short/mid-term.
## New environments
* [SAPIEN](https://sapien.ucsd.edu/)
* [ThreeDWorld](http://www.threedworld.org/)
## New tasks
* [Room-to-room navigation](https://arxiv.org/pdf/1711.07280.pdf)
* [Furniture Lifting](https://arxiv.org/abs/1904.05879) and [Furniture Moving](https://arxiv.org/abs/2007.04979)
## New training methods
* A3C
* Deep Q-Learning
================================================
FILE: allenact/__init__.py
================================================
try:
# noinspection PyProtectedMember,PyUnresolvedReferences
from allenact._version import __version__
except ModuleNotFoundError:
__version__ = None
================================================
FILE: allenact/_constants.py
================================================
import os
from pathlib import Path
ALLENACT_INSTALL_DIR = os.path.abspath(os.path.dirname(Path(__file__)))
================================================
FILE: allenact/algorithms/__init__.py
================================================
================================================
FILE: allenact/algorithms/offpolicy_sync/__init__.py
================================================
================================================
FILE: allenact/algorithms/offpolicy_sync/losses/__init__.py
================================================
================================================
FILE: allenact/algorithms/offpolicy_sync/losses/abstract_offpolicy_loss.py
================================================
"""Defining abstract loss classes for actor critic models."""
import abc
from typing import Dict, Tuple, TypeVar, Generic
import torch
from allenact.algorithms.onpolicy_sync.policy import ObservationType
from allenact.base_abstractions.misc import Loss, Memory
ModelType = TypeVar("ModelType")
class AbstractOffPolicyLoss(Generic[ModelType], Loss):
"""Abstract class representing an off-policy loss function used to train a
model."""
# noinspection PyMethodOverriding
@abc.abstractmethod
def loss( # type: ignore
self,
*, # No positional arguments
step_count: int,
model: ModelType,
batch: ObservationType,
memory: Memory,
**kwargs,
) -> Tuple[torch.FloatTensor, Dict[str, float], Memory, int]:
"""Computes the loss.
Loss after processing a batch of data with (part of) a model (possibly with memory).
# Parameters
model: model to run on data batch (both assumed to be on the same device)
batch: data to use as input for model (already on the same device as model)
memory: model memory before processing current data batch
# Returns
A tuple with:
current_loss: total loss
current_info: additional information about the current loss
memory: model memory after processing current data batch
bsize: batch size
"""
raise NotImplementedError()
================================================
FILE: allenact/algorithms/onpolicy_sync/__init__.py
================================================
================================================
FILE: allenact/algorithms/onpolicy_sync/engine.py
================================================
"""Defines the reinforcement learning `OnPolicyRLEngine`."""
import datetime
import logging
import numbers
import os
import random
import time
import traceback
from functools import partial
from multiprocessing.context import BaseContext
from typing import Any, Dict, List, Optional, Sequence, Union, cast
import filelock
import torch
import torch.distributed as dist # type: ignore
import torch.distributions # type: ignore
import torch.multiprocessing as mp # type: ignore
import torch.nn as nn
import torch.optim as optim
# noinspection PyProtectedMember
from torch._C._distributed_c10d import ReduceOp
from allenact.algorithms.onpolicy_sync.misc import TrackingInfo, TrackingInfoType
from allenact.base_abstractions.sensor import Sensor
from allenact.utils.misc_utils import str2bool
from allenact.utils.model_utils import md5_hash_of_state_dict
try:
# noinspection PyProtectedMember,PyUnresolvedReferences
from torch.optim.lr_scheduler import _LRScheduler
except (ImportError, ModuleNotFoundError):
raise ImportError("`_LRScheduler` was not found in `torch.optim.lr_scheduler`")
from allenact.algorithms.onpolicy_sync.losses.abstract_loss import (
AbstractActorCriticLoss,
)
from allenact.algorithms.onpolicy_sync.policy import ActorCriticModel
from allenact.algorithms.onpolicy_sync.storage import (
ExperienceStorage,
MiniBatchStorageMixin,
RolloutStorage,
StreamingStorageMixin,
)
from allenact.algorithms.onpolicy_sync.vector_sampled_tasks import (
COMPLETE_TASK_CALLBACK_KEY,
COMPLETE_TASK_METRICS_KEY,
SingleProcessVectorSampledTasks,
VectorSampledTasks,
)
from allenact.base_abstractions.distributions import TeacherForcingDistr
from allenact.base_abstractions.experiment_config import ExperimentConfig, MachineParams
from allenact.base_abstractions.misc import (
ActorCriticOutput,
GenericAbstractLoss,
Memory,
RLStepResult,
)
from allenact.utils import spaces_utils as su
from allenact.utils.experiment_utils import (
LoggingPackage,
PipelineStage,
ScalarMeanTracker,
StageComponent,
TrainingPipeline,
set_deterministic_cudnn,
set_seed,
)
from allenact.utils.system import get_logger
from allenact.utils.tensor_utils import batch_observations, detach_recursively
from allenact.utils.viz_utils import VizSuite
try:
# When debugging we don't want to timeout in the VectorSampledTasks
# noinspection PyPackageRequirements
import pydevd
DEBUGGING = str2bool(os.getenv("ALLENACT_DEBUG", "true"))
except ImportError:
DEBUGGING = str2bool(os.getenv("ALLENACT_DEBUG", "false"))
DEBUG_VST_TIMEOUT: Optional[int] = (lambda x: int(x) if x is not None else x)(
os.getenv("ALLENACT_DEBUG_VST_TIMEOUT", None)
)
TRAIN_MODE_STR = "train"
VALID_MODE_STR = "valid"
TEST_MODE_STR = "test"
class OnPolicyRLEngine(object):
"""The reinforcement learning primary controller.
This `OnPolicyRLEngine` class handles all training, validation, and
testing as well as logging and checkpointing. You are not expected
to instantiate this class yourself, instead you should define an
experiment which will then be used to instantiate an
`OnPolicyRLEngine` and perform any desired tasks.
"""
def __init__(
self,
experiment_name: str,
config: ExperimentConfig,
results_queue: mp.Queue, # to output aggregated results
checkpoints_queue: Optional[
mp.Queue
], # to write/read (trainer/evaluator) ready checkpoints
checkpoints_dir: str,
mode: str = "train",
callback_sensors: Optional[Sequence[Sensor]] = None,
seed: Optional[int] = None,
deterministic_cudnn: bool = False,
mp_ctx: Optional[BaseContext] = None,
worker_id: int = 0,
num_workers: int = 1,
device: Union[str, torch.device, int] = "cpu",
distributed_ip: str = "127.0.0.1",
distributed_port: int = 0,
deterministic_agents: bool = False,
max_sampler_processes_per_worker: Optional[int] = None,
initial_model_state_dict: Optional[Union[Dict[str, Any], int]] = None,
try_restart_after_task_error: bool = False,
**kwargs,
):
"""Initializer.
# Parameters
config : The ExperimentConfig defining the experiment to run.
output_dir : Root directory at which checkpoints and logs should be saved.
seed : Seed used to encourage deterministic behavior (it is difficult to ensure
completely deterministic behavior due to CUDA issues and nondeterminism
in environments).
mode : "train", "valid", or "test".
deterministic_cudnn : Whether to use deterministic cudnn. If `True` this may lower
training performance this is necessary (but not sufficient) if you desire
deterministic behavior.
extra_tag : An additional label to add to the experiment when saving tensorboard logs.
"""
self.config = config
self.results_queue = results_queue
self.checkpoints_queue = checkpoints_queue
self.mp_ctx = mp_ctx
self.checkpoints_dir = checkpoints_dir
self.worker_id = worker_id
self.num_workers = num_workers
self.device = torch.device("cpu") if device == -1 else torch.device(device) # type: ignore
if self.device != torch.device("cpu"):
torch.cuda.set_device(device)
self.distributed_ip = distributed_ip
self.distributed_port = distributed_port
self.try_restart_after_task_error = try_restart_after_task_error
self.mode = mode.lower().strip()
assert self.mode in [
TRAIN_MODE_STR,
VALID_MODE_STR,
TEST_MODE_STR,
], f"Only {TRAIN_MODE_STR}, {VALID_MODE_STR}, {TEST_MODE_STR}, modes supported"
self.callback_sensors = callback_sensors
self.deterministic_cudnn = deterministic_cudnn
if self.deterministic_cudnn:
set_deterministic_cudnn()
self.seed = seed
set_seed(self.seed)
self.experiment_name = experiment_name
assert (
max_sampler_processes_per_worker is None
or max_sampler_processes_per_worker >= 1
), "`max_sampler_processes_per_worker` must be either `None` or a positive integer."
self.max_sampler_processes_per_worker = max_sampler_processes_per_worker
machine_params = config.machine_params(self.mode)
self.machine_params: MachineParams
if isinstance(machine_params, MachineParams):
self.machine_params = machine_params
else:
self.machine_params = MachineParams(**machine_params)
self.num_samplers_per_worker = self.machine_params.nprocesses
self.num_samplers = self.num_samplers_per_worker[self.worker_id]
self._vector_tasks: Optional[
Union[VectorSampledTasks, SingleProcessVectorSampledTasks]
] = None
self.sensor_preprocessor_graph = None
self.actor_critic: Optional[ActorCriticModel] = None
create_model_kwargs = {}
if self.machine_params.sensor_preprocessor_graph is not None:
self.sensor_preprocessor_graph = (
self.machine_params.sensor_preprocessor_graph.to(self.device)
)
create_model_kwargs["sensor_preprocessor_graph"] = (
self.sensor_preprocessor_graph
)
set_seed(self.seed)
self.actor_critic = cast(
ActorCriticModel,
self.config.create_model(**create_model_kwargs),
).to(self.device)
if initial_model_state_dict is not None:
if isinstance(initial_model_state_dict, int):
assert (
md5_hash_of_state_dict(self.actor_critic.state_dict())
== initial_model_state_dict
), (
f"Could not reproduce the correct model state dict on worker {self.worker_id} despite seeding."
f" Please ensure that your model's initialization is reproducable when `set_seed(...)`"
f"] has been called with a fixed seed before initialization."
)
else:
self.actor_critic.load_state_dict(
state_dict=cast(
"OrderedDict[str, Tensor]", initial_model_state_dict
)
)
else:
assert mode != TRAIN_MODE_STR or self.num_workers == 1, (
"When training with multiple workers you must pass a,"
" non-`None` value for the `initial_model_state_dict` argument."
)
if get_logger().level == logging.DEBUG:
model_hash = md5_hash_of_state_dict(self.actor_critic.state_dict())
get_logger().debug(
f"[{self.mode} worker {self.worker_id}] model weights hash: {model_hash}"
)
self.is_distributed = False
self.store: Optional[torch.distributed.TCPStore] = None # type:ignore
if self.num_workers > 1:
self.store = torch.distributed.TCPStore( # type:ignore
host_name=self.distributed_ip,
port=self.distributed_port,
world_size=self.num_workers,
is_master=self.worker_id == 0,
timeout=datetime.timedelta(
seconds=3 * (DEBUG_VST_TIMEOUT if DEBUGGING else 1 * 60) + 300
),
)
cpu_device = self.device == torch.device("cpu") # type:ignore
# "gloo" required during testing to ensure that `barrier()` doesn't time out.
backend = "gloo" if cpu_device or self.mode == TEST_MODE_STR else "nccl"
get_logger().debug(
f"Worker {self.worker_id}: initializing distributed {backend} backend with device {self.device}."
)
dist.init_process_group( # type:ignore
backend=backend,
store=self.store,
rank=self.worker_id,
world_size=self.num_workers,
# During testing, we sometimes found that default timeout was too short
# resulting in the run terminating surprisingly, we increase it here.
timeout=(
datetime.timedelta(minutes=3000)
if (self.mode == TEST_MODE_STR or DEBUGGING)
else dist.default_pg_timeout
),
)
self.is_distributed = True
self.deterministic_agents = deterministic_agents
self._is_closing: bool = (
False # Useful for letting the RL runner know if this is closing
)
self._is_closed: bool = False
# Keeping track of metrics and losses during training/inference
self.single_process_metrics: List = []
self.single_process_task_callback_data: List = []
self.tracking_info_list: List[TrackingInfo] = []
# Variables that wil only be instantiated in the trainer
self.optimizer: Optional[optim.optimizer.Optimizer] = None
# noinspection PyProtectedMember
self.lr_scheduler: Optional[_LRScheduler] = None
self.insufficient_data_for_update: Optional[torch.distributed.PrefixStore] = (
None
)
# Training pipeline will be instantiated during training and inference.
# During inference however, it will be instantiated anew on each run of `run_eval`
# and will be set to `None` after the eval run is complete.
self.training_pipeline: Optional[TrainingPipeline] = None
@property
def vector_tasks(
self,
) -> Union[VectorSampledTasks, SingleProcessVectorSampledTasks]:
if self._vector_tasks is None and self.num_samplers > 0:
if self.is_distributed:
total_processes = sum(
self.num_samplers_per_worker
) # TODO this will break the fixed seed for multi-device test
else:
total_processes = self.num_samplers
seeds = self.worker_seeds(
total_processes,
initial_seed=self.seed, # do not update the RNG state (creation might happen after seed resetting)
)
# TODO: The `self.max_sampler_processes_per_worker == 1` case below would be
# great to have but it does not play nicely with us wanting to kill things
# using SIGTERM/SIGINT signals. Would be nice to figure out a solution to
# this at some point.
# if self.max_sampler_processes_per_worker == 1:
# # No need to instantiate a new task sampler processes if we're
# # restricted to one sampler process for this worker.
# self._vector_tasks = SingleProcessVectorSampledTasks(
# make_sampler_fn=self.config.make_sampler_fn,
# sampler_fn_args_list=self.get_sampler_fn_args(seeds),
# )
# else:
self._vector_tasks = VectorSampledTasks(
make_sampler_fn=self.config.make_sampler_fn,
sampler_fn_args=self.get_sampler_fn_args(seeds),
callback_sensors=self.callback_sensors,
multiprocessing_start_method=(
"forkserver" if self.mp_ctx is None else None
),
mp_ctx=self.mp_ctx,
max_processes=self.max_sampler_processes_per_worker,
read_timeout=DEBUG_VST_TIMEOUT if DEBUGGING else 1 * 60,
)
return self._vector_tasks
@staticmethod
def worker_seeds(nprocesses: int, initial_seed: Optional[int]) -> List[int]:
"""Create a collection of seeds for workers without modifying the RNG
state."""
rstate = None # type:ignore
if initial_seed is not None:
rstate = random.getstate()
random.seed(initial_seed)
seeds = [random.randint(0, (2**31) - 1) for _ in range(nprocesses)]
if initial_seed is not None:
random.setstate(rstate)
return seeds
def get_sampler_fn_args(self, seeds: Optional[List[int]] = None):
sampler_devices = self.machine_params.sampler_devices
if self.mode == TRAIN_MODE_STR:
fn = self.config.train_task_sampler_args
elif self.mode == VALID_MODE_STR:
fn = self.config.valid_task_sampler_args
elif self.mode == TEST_MODE_STR:
fn = self.config.test_task_sampler_args
else:
raise NotImplementedError(
f"self.mode must be one of {TRAIN_MODE_STR}, {VALID_MODE_STR}, or {TEST_MODE_STR}."
)
if self.is_distributed:
total_processes = sum(self.num_samplers_per_worker)
process_offset = sum(self.num_samplers_per_worker[: self.worker_id])
else:
total_processes = self.num_samplers
process_offset = 0
sampler_devices_as_ints: Optional[List[int]] = None
if (
self.is_distributed or self.mode == TEST_MODE_STR
) and self.device.index is not None:
sampler_devices_as_ints = [self.device.index]
elif sampler_devices is not None:
sampler_devices_as_ints = [
-1 if sd.index is None else sd.index for sd in sampler_devices
]
return [
fn(
process_ind=process_offset + it,
total_processes=total_processes,
devices=sampler_devices_as_ints,
seeds=seeds,
)
for it in range(self.num_samplers)
]
def checkpoint_load(
self, ckpt: Union[str, Dict[str, Any]], restart_pipeline: bool
) -> Dict[str, Union[Dict[str, Any], torch.Tensor, float, int, str, List]]:
if isinstance(ckpt, str):
get_logger().info(
f"[{self.mode} worker {self.worker_id}] Loading checkpoint from {ckpt}"
)
# Map location CPU is almost always better than mapping to a CUDA device.
ckpt = torch.load(os.path.abspath(ckpt), map_location="cpu")
ckpt = cast(
Dict[str, Union[Dict[str, Any], torch.Tensor, float, int, str, List]],
ckpt,
)
self.actor_critic.load_state_dict(ckpt["model_state_dict"]) # type:ignore
if "training_pipeline_state_dict" in ckpt and not restart_pipeline:
self.training_pipeline.load_state_dict(
cast(Dict[str, Any], ckpt["training_pipeline_state_dict"])
)
return ckpt
# aggregates task metrics currently in queue
def aggregate_task_metrics(
self,
logging_pkg: LoggingPackage,
num_tasks: int = -1,
) -> LoggingPackage:
if num_tasks > 0:
if len(self.single_process_metrics) != num_tasks:
error_msg = (
"shorter"
if len(self.single_process_metrics) < num_tasks
else "longer"
)
get_logger().error(
f"Metrics out is {error_msg} than expected number of tasks."
" This should only happen if a positive number of `num_tasks` were"
" set during testing but the queue did not contain this number of entries."
" Please file an issue at https://github.com/allenai/allenact/issues."
)
num_empty_tasks_dequeued = 0
for metrics_dict in self.single_process_metrics:
num_empty_tasks_dequeued += not logging_pkg.add_metrics_dict(
single_task_metrics_dict=metrics_dict
)
self.single_process_metrics = []
if num_empty_tasks_dequeued != 0:
get_logger().warning(
f"Discarded {num_empty_tasks_dequeued} empty task metrics"
)
return logging_pkg
def _preprocess_observations(self, batched_observations):
if self.sensor_preprocessor_graph is None:
return batched_observations
return self.sensor_preprocessor_graph.get_observations(batched_observations)
def remove_paused(self, observations):
paused, keep, running = [], [], []
for it, obs in enumerate(observations):
if obs is None:
paused.append(it)
else:
keep.append(it)
running.append(obs)
for p in reversed(paused):
self.vector_tasks.pause_at(p)
# Group samplers along new dim:
batch = batch_observations(running, device=self.device)
return len(paused), keep, batch
def initialize_storage_and_viz(
self,
storage_to_initialize: Optional[Sequence[ExperienceStorage]],
visualizer: Optional[VizSuite] = None,
):
keep: Optional[List] = None
if visualizer is not None or (
storage_to_initialize is not None
and any(isinstance(s, RolloutStorage) for s in storage_to_initialize)
):
# No rollout storage, thus we are not
observations = self.vector_tasks.get_observations()
npaused, keep, batch = self.remove_paused(observations)
observations = (
self._preprocess_observations(batch) if len(keep) > 0 else batch
)
assert npaused == 0, f"{npaused} samplers are paused during initialization."
num_samplers = len(keep)
else:
observations = {}
num_samplers = 0
npaused = 0
recurrent_memory_specification = (
self.actor_critic.recurrent_memory_specification
)
if storage_to_initialize is not None:
for s in storage_to_initialize:
s.to(self.device)
s.set_partition(index=self.worker_id, num_parts=self.num_workers)
s.initialize(
observations=observations,
num_samplers=num_samplers,
recurrent_memory_specification=recurrent_memory_specification,
action_space=self.actor_critic.action_space,
)
if visualizer is not None and num_samplers > 0:
visualizer.collect(vector_task=self.vector_tasks, alive=keep)
return npaused
@property
def num_active_samplers(self):
if self.vector_tasks is None:
return 0
return self.vector_tasks.num_unpaused_tasks
def act(
self,
rollout_storage: RolloutStorage,
dist_wrapper_class: Optional[type] = None,
):
with torch.no_grad():
agent_input = rollout_storage.agent_input_for_next_step()
actor_critic_output, memory = self.actor_critic(**agent_input)
distr = actor_critic_output.distributions
if dist_wrapper_class is not None:
distr = dist_wrapper_class(distr=distr, obs=agent_input["observations"])
actions = distr.sample() if not self.deterministic_agents else distr.mode()
return actions, actor_critic_output, memory, agent_input["observations"]
def aggregate_and_send_logging_package(
self,
tracking_info_list: List[TrackingInfo],
logging_pkg: Optional[LoggingPackage] = None,
send_logging_package: bool = True,
checkpoint_file_name: Optional[str] = None,
):
if logging_pkg is None:
logging_pkg = LoggingPackage(
mode=self.mode,
training_steps=self.training_pipeline.total_steps,
pipeline_stage=self.training_pipeline.current_stage_index,
storage_uuid_to_total_experiences=self.training_pipeline.storage_uuid_to_total_experiences,
checkpoint_file_name=checkpoint_file_name,
)
self.aggregate_task_metrics(logging_pkg=logging_pkg)
for callback_dict in self.single_process_task_callback_data:
logging_pkg.task_callback_data.append(callback_dict)
self.single_process_task_callback_data = []
for tracking_info in tracking_info_list:
if tracking_info.n < 0:
get_logger().warning(
f"Obtained a train_info_dict with {tracking_info.n} elements."
f" Full info: ({tracking_info.type}, {tracking_info.info}, {tracking_info.n})."
)
else:
tracking_info_dict = tracking_info.info
if tracking_info.type == TrackingInfoType.LOSS:
tracking_info_dict = {
f"losses/{k}": v for k, v in tracking_info_dict.items()
}
logging_pkg.add_info_dict(
info_dict=tracking_info_dict,
n=tracking_info.n,
stage_component_uuid=tracking_info.stage_component_uuid,
storage_uuid=tracking_info.storage_uuid,
)
if send_logging_package:
self.results_queue.put(logging_pkg)
return logging_pkg
@staticmethod
def _active_memory(memory, keep):
return memory.sampler_select(keep) if memory is not None else memory
def probe(self, dones: List[bool], npaused, period=100000):
"""Debugging util. When called from
self.collect_step_across_all_task_samplers(...), calls render for the
0-th task sampler of the 0-th distributed worker for the first
beginning episode spaced at least period steps from the beginning of
the previous one.
For valid, train, it currently renders all episodes for the 0-th task sampler of the
0-th distributed worker. If this is not wanted, it must be hard-coded for now below.
# Parameters
dones : dones list from self.collect_step_across_all_task_samplers(...)
npaused : number of newly paused tasks returned by self.removed_paused(...)
period : minimal spacing in sampled steps between the beginning of episodes to be shown.
"""
sampler_id = 0
done = dones[sampler_id]
if self.mode != TRAIN_MODE_STR:
setattr(
self, "_probe_npaused", getattr(self, "_probe_npaused", 0) + npaused
)
if self._probe_npaused == self.num_samplers: # type:ignore
del self._probe_npaused # type:ignore
return
period = 0
if self.worker_id == 0:
if done:
if period > 0 and (
getattr(self, "_probe_steps", None) is None
or (
self._probe_steps < 0 # type:ignore
and (
self.training_pipeline.total_steps
+ self._probe_steps # type:ignore
)
>= period
)
):
self._probe_steps = self.training_pipeline.total_steps
if period == 0 or (
getattr(self, "_probe_steps", None) is not None
and self._probe_steps >= 0
and ((self.training_pipeline.total_steps - self._probe_steps) < period)
):
if (
period == 0
or not done
or self._probe_steps == self.training_pipeline.total_steps
):
self.vector_tasks.call_at(sampler_id, "render", ["human"])
else:
# noinspection PyAttributeOutsideInit
self._probe_steps = -self._probe_steps
def collect_step_across_all_task_samplers(
self,
rollout_storage_uuid: str,
uuid_to_storage: Dict[str, ExperienceStorage],
visualizer=None,
dist_wrapper_class=None,
) -> int:
rollout_storage = cast(RolloutStorage, uuid_to_storage[rollout_storage_uuid])
actions, actor_critic_output, memory, _ = self.act(
rollout_storage=rollout_storage,
dist_wrapper_class=dist_wrapper_class,
)
# Flatten actions
flat_actions = su.flatten(self.actor_critic.action_space, actions)
assert len(flat_actions.shape) == 3, (
"Distribution samples must include step and task sampler dimensions [step, sampler, ...]. The simplest way"
"to accomplish this is to pass param tensors (like `logits` in a `CategoricalDistr`) with these dimensions"
"to the Distribution."
)
# Convert flattened actions into list of actions and send them
outputs: List[RLStepResult] = self.vector_tasks.step(
su.action_list(self.actor_critic.action_space, flat_actions)
)
# Save after task completion metrics
for step_result in outputs:
if step_result.info is not None:
if COMPLETE_TASK_METRICS_KEY in step_result.info:
self.single_process_metrics.append(
step_result.info[COMPLETE_TASK_METRICS_KEY]
)
del step_result.info[COMPLETE_TASK_METRICS_KEY]
if COMPLETE_TASK_CALLBACK_KEY in step_result.info:
self.single_process_task_callback_data.append(
step_result.info[COMPLETE_TASK_CALLBACK_KEY]
)
del step_result.info[COMPLETE_TASK_CALLBACK_KEY]
rewards: Union[List, torch.Tensor]
observations, rewards, dones, infos = [list(x) for x in zip(*outputs)]
rewards = torch.tensor(
rewards,
dtype=torch.float,
device=self.device, # type:ignore
)
# We want rewards to have dimensions [sampler, reward]
if len(rewards.shape) == 1:
# Rewards are of shape [sampler,]
rewards = rewards.unsqueeze(-1)
elif len(rewards.shape) > 1:
raise NotImplementedError()
# If done then clean the history of observations.
masks = (
1.0
- torch.tensor(
dones,
dtype=torch.float32,
device=self.device, # type:ignore
)
).view(
-1, 1
) # [sampler, 1]
npaused, keep, batch = self.remove_paused(observations)
if hasattr(self.actor_critic, "sampler_select"):
self.actor_critic.sampler_select(keep)
# TODO self.probe(...) can be useful for debugging (we might want to control it from main?)
# self.probe(dones, npaused)
if npaused > 0:
if self.mode == TRAIN_MODE_STR:
raise NotImplementedError(
"When trying to get a new task from a task sampler (using the `.next_task()` method)"
" the task sampler returned `None`. This is not currently supported during training"
" (and almost certainly a bug in the implementation of the task sampler or in the "
" initialization of the task sampler for training)."
)
for s in uuid_to_storage.values():
if isinstance(s, RolloutStorage):
s.sampler_select(keep)
to_add_to_storage = dict(
observations=(
self._preprocess_observations(batch) if len(keep) > 0 else batch
),
memory=self._active_memory(memory, keep),
actions=flat_actions[0, keep],
action_log_probs=actor_critic_output.distributions.log_prob(actions)[
0, keep
],
value_preds=actor_critic_output.values[0, keep],
rewards=rewards[keep],
masks=masks[keep],
)
for storage in uuid_to_storage.values():
storage.add(**to_add_to_storage)
# TODO we always miss tensors for the last action in the last episode of each worker
if visualizer is not None:
if len(keep) > 0:
visualizer.collect(
rollout=rollout_storage,
vector_task=self.vector_tasks,
alive=keep,
actor_critic=actor_critic_output,
)
else:
visualizer.collect(actor_critic=actor_critic_output)
return npaused
def distributed_weighted_sum(
self,
to_share: Union[torch.Tensor, float, int],
weight: Union[torch.Tensor, float, int],
):
"""Weighted sum of scalar across distributed workers."""
if self.is_distributed:
aggregate = torch.tensor(to_share * weight).to(self.device)
dist.all_reduce(aggregate)
return aggregate.item()
else:
if abs(1 - weight) > 1e-5:
get_logger().warning(
f"Scaling non-distributed value with weight {weight}"
)
return torch.tensor(to_share * weight).item()
def distributed_reduce(
self, to_share: Union[torch.Tensor, float, int], op: ReduceOp
):
"""Weighted sum of scalar across distributed workers."""
if self.is_distributed:
aggregate = torch.tensor(to_share).to(self.device)
dist.all_reduce(aggregate, op=op)
return aggregate.item()
else:
return torch.tensor(to_share).item()
def backprop_step(
self,
total_loss: torch.Tensor,
max_grad_norm: float,
local_to_global_batch_size_ratio: float = 1.0,
):
raise NotImplementedError
def save_error_data(self, batch: Dict[str, Any]):
raise NotImplementedError
@property
def step_count(self) -> int:
if (
self.training_pipeline.current_stage is None
): # Might occur during testing when all stages are complete
return 0
return self.training_pipeline.current_stage.steps_taken_in_stage
def compute_losses_track_them_and_backprop(
self,
stage: PipelineStage,
stage_component: StageComponent,
storage: ExperienceStorage,
skip_backprop: bool = False,
):
training = self.mode == TRAIN_MODE_STR
assert training or skip_backprop
if training and self.is_distributed:
self.insufficient_data_for_update.set(
"insufficient_data_for_update", str(0)
)
dist.barrier(
device_ids=(
None if self.device == torch.device("cpu") else [self.device.index]
)
)
training_settings = stage_component.training_settings
loss_names = stage_component.loss_names
losses = [self.training_pipeline.get_loss(ln) for ln in loss_names]
loss_weights = [stage.uuid_to_loss_weight[ln] for ln in loss_names]
loss_update_repeats_list = training_settings.update_repeats
if isinstance(loss_update_repeats_list, numbers.Integral):
loss_update_repeats_list = [loss_update_repeats_list] * len(loss_names)
if skip_backprop and isinstance(storage, MiniBatchStorageMixin):
if loss_update_repeats_list != [1] * len(loss_names):
loss_update_repeats_list = [1] * len(loss_names)
get_logger().warning(
"Does not make sense to do multiple updates when"
" skip_backprop is `True` and you are using a storage of type"
" `MiniBatchStorageMixin`. This is likely a problem caused by"
" using a custom valid/test stage component that is inheriting its"
" TrainingSettings from the TrainingPipeline's TrainingSettings. We will override"
" the requested number of updates repeats (which was"
f" {dict(zip(loss_names, loss_update_repeats_list))}) to be 1 for all losses."
)
enough_data_for_update = True
for current_update_repeat_index in range(
max(loss_update_repeats_list, default=0)
):
if isinstance(storage, MiniBatchStorageMixin):
batch_iterator = storage.batched_experience_generator(
num_mini_batch=training_settings.num_mini_batch
)
elif isinstance(storage, StreamingStorageMixin):
assert (
training_settings.num_mini_batch is None
or training_settings.num_mini_batch == 1
)
def single_batch_generator(streaming_storage: StreamingStorageMixin):
try:
yield cast(
StreamingStorageMixin, streaming_storage
).next_batch()
except EOFError:
if not training:
raise
if streaming_storage.empty():
yield None
else:
cast(
StreamingStorageMixin, streaming_storage
).reset_stream()
stage.stage_component_uuid_to_stream_memory[
stage_component.uuid
].clear()
yield cast(
StreamingStorageMixin, streaming_storage
).next_batch()
batch_iterator = single_batch_generator(streaming_storage=storage)
else:
raise NotImplementedError(
f"Storage {storage} must be a subclass of `MiniBatchStorageMixin` or `StreamingStorageMixin`."
)
for batch in batch_iterator:
if batch is None:
# This should only happen in a `StreamingStorageMixin` when it cannot
# generate an initial batch or when we are in testing/validation and
# we've reached the end of the dataset over which to test/validate.
if training:
assert isinstance(storage, StreamingStorageMixin)
get_logger().warning(
f"Worker {self.worker_id}: could not run update in {storage}, potentially because"
f" not enough data has been accumulated to be able to fill an initial batch."
)
else:
pass
enough_data_for_update = False
if training and self.is_distributed:
self.insufficient_data_for_update.add(
"insufficient_data_for_update",
1 * (not enough_data_for_update),
)
dist.barrier(
device_ids=(
None
if self.device == torch.device("cpu")
else [self.device.index]
)
)
if (
int(
self.insufficient_data_for_update.get(
"insufficient_data_for_update"
)
)
!= 0
):
enough_data_for_update = False
break
info: Dict[str, float] = {}
bsize: Optional[int] = None
total_loss: Optional[torch.Tensor] = None
actor_critic_output_for_batch: Optional[ActorCriticOutput] = None
batch_memory = Memory()
for loss, loss_name, loss_weight, max_update_repeats_for_loss in zip(
losses, loss_names, loss_weights, loss_update_repeats_list
):
if current_update_repeat_index >= max_update_repeats_for_loss:
continue
if isinstance(loss, AbstractActorCriticLoss):
bsize = batch["bsize"]
if actor_critic_output_for_batch is None:
try:
actor_critic_output_for_batch, _ = self.actor_critic(
observations=batch["observations"],
memory=batch["memory"],
prev_actions=batch["prev_actions"],
masks=batch["masks"],
)
except ValueError:
save_path = self.save_error_data(batch=batch)
get_logger().error(
f"Encountered a value error! Likely because of nans in the output/input."
f" Saving all error information to {save_path}."
)
raise
loss_return = loss.loss(
step_count=self.step_count,
batch=batch,
actor_critic_output=actor_critic_output_for_batch,
)
per_epoch_info = {}
if len(loss_return) == 2:
current_loss, current_info = loss_return
elif len(loss_return) == 3:
current_loss, current_info, per_epoch_info = loss_return
else:
raise NotImplementedError
elif isinstance(loss, GenericAbstractLoss):
loss_output = loss.loss(
model=self.actor_critic,
batch=batch,
batch_memory=batch_memory,
stream_memory=stage.stage_component_uuid_to_stream_memory[
stage_component.uuid
],
)
current_loss = loss_output.value
current_info = loss_output.info
per_epoch_info = loss_output.per_epoch_info
batch_memory = loss_output.batch_memory
stage.stage_component_uuid_to_stream_memory[
stage_component.uuid
] = loss_output.stream_memory
bsize = loss_output.bsize
else:
raise NotImplementedError(
f"Loss of type {type(loss)} is not supported. Losses must be subclasses of"
f" `AbstractActorCriticLoss` or `GenericAbstractLoss`."
)
if total_loss is None:
total_loss = loss_weight * current_loss
else:
total_loss = total_loss + loss_weight * current_loss
for key, value in current_info.items():
info[f"{loss_name}/{key}"] = value
if per_epoch_info is not None:
for key, value in per_epoch_info.items():
if max(loss_update_repeats_list, default=0) > 1:
info[
f"{loss_name}/{key}_epoch{current_update_repeat_index:02d}"
] = value
info[f"{loss_name}/{key}_combined"] = value
else:
info[f"{loss_name}/{key}"] = value
assert total_loss is not None, (
f"No {stage_component.uuid} losses specified for training in stage"
f" {self.training_pipeline.current_stage_index}"
)
total_loss_scalar = total_loss.item()
info[f"total_loss"] = total_loss_scalar
self.tracking_info_list.append(
TrackingInfo(
type=TrackingInfoType.LOSS,
info=info,
n=bsize,
storage_uuid=stage_component.storage_uuid,
stage_component_uuid=stage_component.uuid,
)
)
to_track = {
"rollout_epochs": max(loss_update_repeats_list, default=0),
"worker_batch_size": bsize,
}
aggregate_bsize = None
if training:
aggregate_bsize = self.distributed_weighted_sum(bsize, 1)
to_track["global_batch_size"] = aggregate_bsize
to_track["lr"] = self.optimizer.param_groups[0]["lr"]
if training_settings.num_mini_batch is not None:
to_track["rollout_num_mini_batch"] = (
training_settings.num_mini_batch
)
for k, v in to_track.items():
# We need to set the bsize to 1 for `worker_batch_size` below as we're trying to record the
# average batch size per worker, not the average per worker weighted by the size of the batches
# of those workers.
self.tracking_info_list.append(
TrackingInfo(
type=TrackingInfoType.UPDATE_INFO,
info={k: v},
n=1 if k == "worker_batch_size" else bsize,
storage_uuid=stage_component.storage_uuid,
stage_component_uuid=stage_component.uuid,
)
)
if not skip_backprop:
total_grad_norm = self.backprop_step(
total_loss=total_loss,
max_grad_norm=training_settings.max_grad_norm,
local_to_global_batch_size_ratio=bsize / aggregate_bsize,
)
self.tracking_info_list.append(
TrackingInfo(
type=TrackingInfoType.UPDATE_INFO,
info={"total_grad_norm": total_grad_norm},
n=bsize,
storage_uuid=stage_component.storage_uuid,
stage_component_uuid=stage_component.uuid,
)
)
stage.stage_component_uuid_to_stream_memory[stage_component.uuid] = (
detach_recursively(
input=stage.stage_component_uuid_to_stream_memory[
stage_component.uuid
],
inplace=True,
)
)
def close(self, verbose=True):
self._is_closing = True
if "_is_closed" in self.__dict__ and self._is_closed:
return
def logif(s: Union[str, Exception]):
if verbose:
if isinstance(s, str):
get_logger().info(s)
elif isinstance(s, Exception):
get_logger().error(traceback.format_exc())
else:
raise NotImplementedError()
if "_vector_tasks" in self.__dict__ and self._vector_tasks is not None:
try:
logif(
f"[{self.mode} worker {self.worker_id}] Closing OnPolicyRLEngine.vector_tasks."
)
self._vector_tasks.close()
logif(f"[{self.mode} worker {self.worker_id}] Closed.")
except Exception as e:
logif(
f"[{self.mode} worker {self.worker_id}] Exception raised when closing OnPolicyRLEngine.vector_tasks:"
)
logif(e)
self._is_closed = True
self._is_closing = False
@property
def is_closed(self):
return self._is_closed
@property
def is_closing(self):
return self._is_closing
def __del__(self):
self.close(verbose=False)
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.close(verbose=False)
class OnPolicyTrainer(OnPolicyRLEngine):
def __init__(
self,
experiment_name: str,
config: ExperimentConfig,
results_queue: mp.Queue,
checkpoints_queue: Optional[mp.Queue],
checkpoints_dir: str = "",
seed: Optional[int] = None,
deterministic_cudnn: bool = False,
mp_ctx: Optional[BaseContext] = None,
worker_id: int = 0,
num_workers: int = 1,
device: Union[str, torch.device, int] = "cpu",
distributed_ip: str = "127.0.0.1",
distributed_port: int = 0,
deterministic_agents: bool = False,
distributed_preemption_threshold: float = 0.7,
max_sampler_processes_per_worker: Optional[int] = None,
save_ckpt_after_every_pipeline_stage: bool = True,
first_local_worker_id: int = 0,
save_ckpt_at_every_host: bool = False,
**kwargs,
):
kwargs["mode"] = TRAIN_MODE_STR
super().__init__(
experiment_name=experiment_name,
config=config,
results_queue=results_queue,
checkpoints_queue=checkpoints_queue,
checkpoints_dir=checkpoints_dir,
seed=seed,
deterministic_cudnn=deterministic_cudnn,
mp_ctx=mp_ctx,
worker_id=worker_id,
num_workers=num_workers,
device=device,
distributed_ip=distributed_ip,
distributed_port=distributed_port,
deterministic_agents=deterministic_agents,
max_sampler_processes_per_worker=max_sampler_processes_per_worker,
**kwargs,
)
self.save_ckpt_after_every_pipeline_stage = save_ckpt_after_every_pipeline_stage
self.actor_critic.train()
self.training_pipeline: TrainingPipeline = config.training_pipeline()
if self.num_workers != 1:
# Ensure that we're only using early stopping criterions in the non-distributed setting.
if any(
stage.early_stopping_criterion is not None
for stage in self.training_pipeline.pipeline_stages
):
raise NotImplementedError(
"Early stopping criterions are currently only allowed when using a single training worker, i.e."
" no distributed (multi-GPU) training. If this is a feature you'd like please create an issue"
" at https://github.com/allenai/allenact/issues or (even better) create a pull request with this "
" feature and we'll be happy to review it."
)
self.optimizer: optim.optimizer.Optimizer = (
self.training_pipeline.optimizer_builder(
params=[p for p in self.actor_critic.parameters() if p.requires_grad]
)
)
# noinspection PyProtectedMember
self.lr_scheduler: Optional[_LRScheduler] = None
if self.training_pipeline.lr_scheduler_builder is not None:
self.lr_scheduler = self.training_pipeline.lr_scheduler_builder(
optimizer=self.optimizer
)
if self.is_distributed:
# Tracks how many workers have finished their rollout
self.num_workers_done = torch.distributed.PrefixStore( # type:ignore
"num_workers_done", self.store
)
# Tracks the number of steps taken by each worker in current rollout
self.num_workers_steps = torch.distributed.PrefixStore( # type:ignore
"num_workers_steps", self.store
)
self.distributed_preemption_threshold = distributed_preemption_threshold
# Flag for finished worker in current epoch
self.offpolicy_epoch_done = torch.distributed.PrefixStore( # type:ignore
"offpolicy_epoch_done", self.store
)
# Flag for finished worker in current epoch with custom component
self.insufficient_data_for_update = (
torch.distributed.PrefixStore( # type:ignore
"insufficient_data_for_update", self.store
)
)
else:
self.num_workers_done = None
self.num_workers_steps = None
self.distributed_preemption_threshold = 1.0
self.offpolicy_epoch_done = None
# Keeping track of training state
self.former_steps: Optional[int] = None
self.last_log: Optional[int] = None
self.last_save: Optional[int] = None
# The `self._last_aggregated_train_task_metrics` attribute defined
# below is used for early stopping criterion computations
self._last_aggregated_train_task_metrics: ScalarMeanTracker = (
ScalarMeanTracker()
)
self.first_local_worker_id = first_local_worker_id
self.save_ckpt_at_every_host = save_ckpt_at_every_host
def advance_seed(
self, seed: Optional[int], return_same_seed_per_worker=False
) -> Optional[int]:
if seed is None:
return seed
seed = (seed ^ (self.training_pipeline.total_steps + 1)) % (
2**31 - 1
) # same seed for all workers
if (not return_same_seed_per_worker) and (
self.mode == TRAIN_MODE_STR or self.mode == TEST_MODE_STR
):
return self.worker_seeds(self.num_workers, seed)[
self.worker_id
] # doesn't modify the current rng state
else:
return self.worker_seeds(1, seed)[0] # doesn't modify the current rng state
def deterministic_seeds(self) -> None:
if self.seed is not None:
set_seed(self.advance_seed(self.seed)) # known state for all workers
seeds = self.worker_seeds(
self.num_samplers, None
) # use the latest seed for workers and update rng state
if self.vector_tasks is not None:
self.vector_tasks.set_seeds(seeds)
def save_error_data(self, batch: Dict[str, Any]) -> str:
model_path = os.path.join(
self.checkpoints_dir,
"error_for_exp_{}__stage_{:02d}__steps_{:012d}.pt".format(
self.experiment_name,
self.training_pipeline.current_stage_index,
self.training_pipeline.total_steps,
),
)
with filelock.FileLock(
os.path.join(self.checkpoints_dir, "error.lock"), timeout=60
):
if not os.path.exists(model_path):
save_dict = {
"model_state_dict": self.actor_critic.state_dict(), # type:ignore
"total_steps": self.training_pipeline.total_steps, # Total steps including current stage
"optimizer_state_dict": self.optimizer.state_dict(), # type: ignore
"training_pipeline_state_dict": self.training_pipeline.state_dict(),
"trainer_seed": self.seed,
"batch": batch,
}
if self.lr_scheduler is not None:
save_dict["scheduler_state"] = cast(
_LRScheduler, self.lr_scheduler
).state_dict()
torch.save(save_dict, model_path)
return model_path
def aggregate_and_send_logging_package(
self,
tracking_info_list: List[TrackingInfo],
logging_pkg: Optional[LoggingPackage] = None,
send_logging_package: bool = True,
checkpoint_file_name: Optional[str] = None,
):
logging_pkg = super().aggregate_and_send_logging_package(
tracking_info_list=tracking_info_list,
logging_pkg=logging_pkg,
send_logging_package=send_logging_package,
checkpoint_file_name=checkpoint_file_name,
)
if self.mode == TRAIN_MODE_STR:
# Technically self.mode should always be "train" here (as this is the training engine),
# this conditional is defensive
self._last_aggregated_train_task_metrics.add_scalars(
scalars=logging_pkg.metrics_tracker.means(),
n=logging_pkg.metrics_tracker.counts(),
)
return logging_pkg
def checkpoint_save(self, pipeline_stage_index: Optional[int] = None) -> str:
model_path = os.path.join(
self.checkpoints_dir,
"exp_{}__stage_{:02d}__steps_{:012d}.pt".format(
self.experiment_name,
(
self.training_pipeline.current_stage_index
if pipeline_stage_index is None
else pipeline_stage_index
),
self.training_pipeline.total_steps,
),
)
save_dict = {
"model_state_dict": self.actor_critic.state_dict(), # type:ignore
"total_steps": self.training_pipeline.total_steps, # Total steps including current stage
"optimizer_state_dict": self.optimizer.state_dict(), # type: ignore
"training_pipeline_state_dict": self.training_pipeline.state_dict(),
"trainer_seed": self.seed,
}
if self.lr_scheduler is not None:
save_dict["scheduler_state"] = cast(
_LRScheduler, self.lr_scheduler
).state_dict()
torch.save(save_dict, model_path)
return model_path
def checkpoint_load(
self, ckpt: Union[str, Dict[str, Any]], restart_pipeline: bool = False
) -> Dict[str, Union[Dict[str, Any], torch.Tensor, float, int, str, List]]:
if restart_pipeline:
if "training_pipeline_state_dict" in ckpt:
del ckpt["training_pipeline_state_dict"]
ckpt = super().checkpoint_load(ckpt, restart_pipeline=restart_pipeline)
if restart_pipeline:
self.training_pipeline.restart_pipeline()
else:
self.seed = cast(int, ckpt["trainer_seed"])
self.optimizer.load_state_dict(ckpt["optimizer_state_dict"]) # type: ignore
if self.lr_scheduler is not None and "scheduler_state" in ckpt:
self.lr_scheduler.load_state_dict(ckpt["scheduler_state"]) # type: ignore
self.deterministic_seeds()
return ckpt
@property
def step_count(self):
return self.training_pipeline.current_stage.steps_taken_in_stage
@step_count.setter
def step_count(self, val: int) -> None:
self.training_pipeline.current_stage.steps_taken_in_stage = val
@property
def log_interval(self):
return (
self.training_pipeline.current_stage.training_settings.metric_accumulate_interval
)
@property
def approx_steps(self):
if self.is_distributed:
# the actual number of steps gets synchronized after each rollout
return (
self.step_count - self.former_steps
) * self.num_workers + self.former_steps
else:
return self.step_count # this is actually accurate
def act(
self,
rollout_storage: RolloutStorage,
dist_wrapper_class: Optional[type] = None,
):
if self.training_pipeline.current_stage.teacher_forcing is not None:
assert dist_wrapper_class is None
def tracking_callback(type: TrackingInfoType, info: Dict[str, Any], n: int):
self.tracking_info_list.append(
TrackingInfo(
type=type,
info=info,
n=n,
storage_uuid=self.training_pipeline.rollout_storage_uuid,
stage_component_uuid=None,
)
)
dist_wrapper_class = partial(
TeacherForcingDistr,
action_space=self.actor_critic.action_space,
num_active_samplers=self.num_active_samplers,
approx_steps=self.approx_steps,
teacher_forcing=self.training_pipeline.current_stage.teacher_forcing,
tracking_callback=tracking_callback,
)
actions, actor_critic_output, memory, step_observation = super().act(
rollout_storage=rollout_storage,
dist_wrapper_class=dist_wrapper_class,
)
self.step_count += self.num_active_samplers
return actions, actor_critic_output, memory, step_observation
def advantage_stats(self, advantages: torch.Tensor) -> Dict[str, torch.Tensor]:
r"""Computes the mean and variances of advantages (possibly over multiple workers).
For multiple workers, this method is equivalent to first collecting all versions of
advantages and then computing the mean and variance locally over that.
# Parameters
advantages: Tensors to compute mean and variance over. Assumed to be solely the
worker's local copy of this tensor, the resultant mean and variance will be computed
as though _all_ workers' versions of this tensor were concatenated together in
distributed training.
"""
# Step count has already been updated with the steps from all workers
global_rollout_steps = self.step_count - self.former_steps
if self.is_distributed:
summed_advantages = advantages.sum()
dist.all_reduce(summed_advantages)
mean = summed_advantages / global_rollout_steps
summed_squares = (advantages - mean).pow(2).sum()
dist.all_reduce(summed_squares)
std = (summed_squares / (global_rollout_steps - 1)).sqrt()
else:
# noinspection PyArgumentList
mean, std = advantages.mean(), advantages.std()
return {"mean": mean, "std": std}
def backprop_step(
self,
total_loss: torch.Tensor,
max_grad_norm: float,
local_to_global_batch_size_ratio: float = 1.0,
):
self.optimizer.zero_grad() # type: ignore
if isinstance(total_loss, torch.Tensor):
total_loss.backward()
if self.is_distributed:
# From https://github.com/pytorch/pytorch/issues/43135
reductions, all_params = [], []
for p in self.actor_critic.parameters():
# you can also organize grads to larger buckets to make all_reduce more efficient
if p.requires_grad:
if p.grad is None:
p.grad = torch.zeros_like(p.data)
else: # local_global_batch_size_tuple is not None, since we're distributed:
p.grad = p.grad * local_to_global_batch_size_ratio
reductions.append(
dist.all_reduce(
p.grad,
async_op=True,
) # sum
) # synchronize
all_params.append(p)
for reduction, p in zip(reductions, all_params):
reduction.wait()
if hasattr(self.actor_critic, "compute_total_grad_norm"):
total_grad_norm = self.actor_critic.compute_total_grad_norm().item()
else:
total_grad_norm = 0.0
nn.utils.clip_grad_norm_(
self.actor_critic.parameters(),
max_norm=max_grad_norm, # type: ignore
)
self.optimizer.step() # type: ignore
return total_grad_norm
def _save_checkpoint_then_send_checkpoint_for_validation_and_update_last_save_counter(
self, pipeline_stage_index: Optional[int] = None
):
model_path = None
self.deterministic_seeds()
if (
self.save_ckpt_at_every_host
and self.worker_id == self.first_local_worker_id
) or self.worker_id == 0:
model_path = self.checkpoint_save(pipeline_stage_index=pipeline_stage_index)
if self.checkpoints_queue is not None:
self.checkpoints_queue.put(("eval", model_path))
self.last_save = self.training_pipeline.total_steps
return model_path
def run_pipeline(self, valid_on_initial_weights: bool = False):
cur_stage_training_settings = (
self.training_pipeline.current_stage.training_settings
)
# Change engine attributes that depend on the current stage
self.training_pipeline.current_stage.change_engine_attributes(self)
rollout_storage = self.training_pipeline.rollout_storage
uuid_to_storage = self.training_pipeline.current_stage_storage
self.initialize_storage_and_viz(
storage_to_initialize=cast(
List[ExperienceStorage], list(uuid_to_storage.values())
)
)
self.tracking_info_list.clear()
self.last_log = self.training_pipeline.total_steps
if self.last_save is None:
self.last_save = self.training_pipeline.total_steps
should_save_checkpoints = (
self.checkpoints_dir != ""
and cur_stage_training_settings.save_interval is not None
and cur_stage_training_settings.save_interval > 0
)
already_saved_checkpoint = False
if (
valid_on_initial_weights
and should_save_checkpoints
and self.checkpoints_queue is not None
):
if (
self.save_ckpt_at_every_host
and self.worker_id == self.first_local_worker_id
) or self.worker_id == 0:
model_path = self.checkpoint_save()
if self.checkpoints_queue is not None:
self.checkpoints_queue.put(("eval", model_path))
while True:
pipeline_stage_changed = self.training_pipeline.before_rollout(
train_metrics=self._last_aggregated_train_task_metrics
) # This is `False` at the very start of training, i.e. pipeline starts with a stage initialized
self._last_aggregated_train_task_metrics.reset()
training_is_complete = self.training_pipeline.current_stage is None
# `training_is_complete` should imply `pipeline_stage_changed`
assert pipeline_stage_changed or not training_is_complete
# Saving checkpoints and initializing storage when the pipeline stage changes
if pipeline_stage_changed:
# Here we handle saving a checkpoint after a pipeline stage ends. We
# do this:
# (1) after every pipeline stage if the `self.save_ckpt_after_every_pipeline_stage`
# boolean is True, and
# (2) when we have reached the end of ALL training (i.e. all stages are complete).
if (
should_save_checkpoints
and ( # Might happen if the `save_interval` was hit just previously, see below
not already_saved_checkpoint
)
and (
self.save_ckpt_after_every_pipeline_stage
or training_is_complete
)
):
self._save_checkpoint_then_send_checkpoint_for_validation_and_update_last_save_counter(
pipeline_stage_index=(
self.training_pipeline.current_stage_index - 1
if not training_is_complete
else len(self.training_pipeline.pipeline_stages) - 1
)
)
# If training is complete, break out
if training_is_complete:
break
# Here we handle updating our training settings after a pipeline stage ends.
# Update the training settings we're using
cur_stage_training_settings = (
self.training_pipeline.current_stage.training_settings
)
# If the pipeline stage changed we must initialize any new custom storage and
# stop updating any custom storage that is no longer in use (this second bit
# is done by simply updating `uuid_to_storage` to the new custom storage objects).
new_uuid_to_storage = self.training_pipeline.current_stage_storage
storage_to_initialize = [
s
for uuid, s in new_uuid_to_storage.items()
if uuid
not in uuid_to_storage # Don't initialize storage already in use
]
self.initialize_storage_and_viz(
storage_to_initialize=storage_to_initialize,
)
uuid_to_storage = new_uuid_to_storage
# Change engine attributes that depend on the current stage
self.training_pipeline.current_stage.change_engine_attributes(self)
already_saved_checkpoint = False
if self.is_distributed:
self.num_workers_done.set("done", str(0))
self.num_workers_steps.set("steps", str(0))
# Ensure all workers are done before incrementing num_workers_{steps, done}
dist.barrier(
device_ids=(
None
if self.device == torch.device("cpu")
else [self.device.index]
)
)
self.former_steps = self.step_count
former_storage_experiences = {
k: v.total_experiences
for k, v in self.training_pipeline.current_stage_storage.items()
}
if self.training_pipeline.rollout_storage_uuid is None:
# In this case we're not expecting to collect storage experiences, i.e. everything
# will be off-policy.
# self.step_count is normally updated by the `self.collect_step_across_all_task_samplers`
# call below, but since we're not collecting onpolicy experiences, we need to update
# it here. The step count here is now just effectively a count of the number of times
# we've called `compute_losses_track_them_and_backprop` below.
self.step_count += 1
before_update_info = dict(
next_value=None,
use_gae=cur_stage_training_settings.use_gae,
gamma=cur_stage_training_settings.gamma,
tau=cur_stage_training_settings.gae_lambda,
adv_stats_callback=self.advantage_stats,
)
else:
vector_tasks_already_restarted = False
step = -1
while step < cur_stage_training_settings.num_steps - 1:
step += 1
try:
num_paused = self.collect_step_across_all_task_samplers(
rollout_storage_uuid=self.training_pipeline.rollout_storage_uuid,
uuid_to_storage=uuid_to_storage,
)
except (TimeoutError, EOFError) as e:
if (
not self.try_restart_after_task_error
) or self.mode != TRAIN_MODE_STR:
# Apparently you can just call `raise` here and doing so will just raise the exception as though
# it was not caught (so the stacktrace isn't messed up)
raise
elif vector_tasks_already_restarted:
raise RuntimeError(
f"[{self.mode} worker {self.worker_id}] `vector_tasks` has timed out twice in the same"
f" rollout. This suggests that this error was not recoverable. Timeout exception:\n{traceback.format_exc()}"
)
else:
get_logger().warning(
f"[{self.mode} worker {self.worker_id}] `vector_tasks` appears to have crashed during"
f" training due to an {type(e).__name__} error. You have set"
f" `try_restart_after_task_error` to `True` so we will attempt to restart these tasks from"
f" the beginning. USE THIS FEATURE AT YOUR OWN"
f" RISK. Exception:\n{traceback.format_exc()}."
)
self.vector_tasks.close()
self._vector_tasks = None
vector_tasks_already_restarted = True
for (
storage
) in self.training_pipeline.current_stage_storage.values():
storage.after_updates()
self.initialize_storage_and_viz(
storage_to_initialize=cast(
List[ExperienceStorage],
list(uuid_to_storage.values()),
)
)
step = -1
continue
# A more informative error message should already have been thrown in be given in
# `collect_step_across_all_task_samplers` if `num_paused != 0` here but this serves
# as a sanity check.
assert num_paused == 0
if self.is_distributed:
# Preempt stragglers
# Each worker will stop collecting steps for the current rollout whenever a
# 100 * distributed_preemption_threshold percentage of workers are finished collecting their
# rollout steps, and we have collected at least 25% but less than 90% of the steps.
num_done = int(self.num_workers_done.get("done"))
if (
num_done
> self.distributed_preemption_threshold * self.num_workers
and 0.25 * cur_stage_training_settings.num_steps
<= step
< 0.9 * cur_stage_training_settings.num_steps
):
get_logger().debug(
f"[{self.mode} worker {self.worker_id}] Preempted after {step}"
f" steps (out of {cur_stage_training_settings.num_steps})"
f" with {num_done} workers done"
)
break
with torch.no_grad():
actor_critic_output, _ = self.actor_critic(
**rollout_storage.agent_input_for_next_step()
)
self.training_pipeline.rollout_count += 1
if self.is_distributed:
# Mark that a worker is done collecting experience
self.num_workers_done.add("done", 1)
self.num_workers_steps.add(
"steps", self.step_count - self.former_steps
)
# Ensure all workers are done before updating step counter
dist.barrier(
device_ids=(
None
if self.device == torch.device("cpu")
else [self.device.index]
)
)
ndone = int(self.num_workers_done.get("done"))
assert (
ndone == self.num_workers
), f"# workers done {ndone} != # workers {self.num_workers}"
# get the actual step_count
self.step_count = (
int(self.num_workers_steps.get("steps")) + self.former_steps
)
before_update_info = dict(
next_value=actor_critic_output.values.detach(),
use_gae=cur_stage_training_settings.use_gae,
gamma=cur_stage_training_settings.gamma,
tau=cur_stage_training_settings.gae_lambda,
adv_stats_callback=self.advantage_stats,
)
# Prepare storage for iteration during updates
for storage in self.training_pipeline.current_stage_storage.values():
storage.before_updates(**before_update_info)
for sc in self.training_pipeline.current_stage.stage_components:
component_storage = uuid_to_storage[sc.storage_uuid]
self.compute_losses_track_them_and_backprop(
stage=self.training_pipeline.current_stage,
stage_component=sc,
storage=component_storage,
)
for storage in self.training_pipeline.current_stage_storage.values():
storage.after_updates()
# We update the storage step counts saved in
# `self.training_pipeline.current_stage.storage_uuid_to_steps_taken_in_stage` here rather than with
# `self.steps` above because some storage step counts may only change after the update calls above.
# This may seem a bit weird but consider a storage that corresponds to a fixed dataset
# used for imitation learning. For such a dataset, the "steps" will only increase as
# new batches are sampled during update calls.
# Note: We don't need to sort the keys below to ensure that distributed updates happen correctly
# as `self.training_pipeline.current_stage_storage` is an ordered `dict`.
# First we calculate the change in counts (possibly aggregating across devices)
change_in_storage_experiences = {}
for k in sorted(self.training_pipeline.current_stage_storage.keys()):
delta = (
self.training_pipeline.current_stage_storage[k].total_experiences
- former_storage_experiences[k]
)
assert delta >= 0
change_in_storage_experiences[k] = self.distributed_weighted_sum(
to_share=delta, weight=1
)
# Then we update `self.training_pipeline.current_stage.storage_uuid_to_steps_taken_in_stage` with the above
# computed changes.
for storage_uuid, delta in change_in_storage_experiences.items():
self.training_pipeline.current_stage.storage_uuid_to_steps_taken_in_stage[
storage_uuid
] += delta
if self.lr_scheduler is not None:
self.lr_scheduler.step(epoch=self.training_pipeline.total_steps)
# Here we handle saving a checkpoint every `save_interval` steps, saving after
# a pipeline stage completes is controlled above
checkpoint_file_name = None
if should_save_checkpoints and (
self.training_pipeline.total_steps - self.last_save
>= cur_stage_training_settings.save_interval
):
checkpoint_file_name = (
self._save_checkpoint_then_send_checkpoint_for_validation_and_update_last_save_counter()
)
already_saved_checkpoint = True
if (
self.training_pipeline.total_steps - self.last_log >= self.log_interval
or self.training_pipeline.current_stage.is_complete
):
self.aggregate_and_send_logging_package(
tracking_info_list=self.tracking_info_list,
checkpoint_file_name=checkpoint_file_name,
)
self.tracking_info_list.clear()
self.last_log = self.training_pipeline.total_steps
if (
cur_stage_training_settings.advance_scene_rollout_period is not None
) and (
self.training_pipeline.rollout_count
% cur_stage_training_settings.advance_scene_rollout_period
== 0
):
get_logger().info(
f"[{self.mode} worker {self.worker_id}] Force advance"
f" tasks with {self.training_pipeline.rollout_count} rollouts"
)
self.vector_tasks.next_task(force_advance_scene=True)
self.initialize_storage_and_viz(
storage_to_initialize=cast(
List[ExperienceStorage], list(uuid_to_storage.values())
)
)
def train(
self,
checkpoint_file_name: Optional[str] = None,
restart_pipeline: bool = False,
valid_on_initial_weights: bool = False,
):
assert (
self.mode == TRAIN_MODE_STR
), "train only to be called from a train instance"
training_completed_successfully = False
# noinspection PyBroadException
try:
if checkpoint_file_name is not None:
self.checkpoint_load(checkpoint_file_name, restart_pipeline)
self.run_pipeline(valid_on_initial_weights=valid_on_initial_weights)
training_completed_successfully = True
except KeyboardInterrupt:
get_logger().info(
f"[{self.mode} worker {self.worker_id}] KeyboardInterrupt, exiting."
)
except Exception as e:
get_logger().error(
f"[{self.mode} worker {self.worker_id}] Encountered {type(e).__name__}, exiting."
)
get_logger().error(traceback.format_exc())
finally:
if training_completed_successfully:
if self.worker_id == 0:
self.results_queue.put(("train_stopped", 0))
get_logger().info(
f"[{self.mode} worker {self.worker_id}] Training finished successfully."
)
else:
self.results_queue.put(("train_stopped", 1 + self.worker_id))
self.close()
class OnPolicyInference(OnPolicyRLEngine):
def __init__(
self,
config: ExperimentConfig,
results_queue: mp.Queue, # to output aggregated results
checkpoints_queue: mp.Queue, # to write/read (trainer/evaluator) ready checkpoints
checkpoints_dir: str = "",
mode: str = "valid", # or "test"
seed: Optional[int] = None,
deterministic_cudnn: bool = False,
mp_ctx: Optional[BaseContext] = None,
device: Union[str, torch.device, int] = "cpu",
deterministic_agents: bool = False,
worker_id: int = 0,
num_workers: int = 1,
distributed_port: int = 0,
enforce_expert: bool = False,
**kwargs,
):
super().__init__(
experiment_name="",
config=config,
results_queue=results_queue,
checkpoints_queue=checkpoints_queue,
checkpoints_dir=checkpoints_dir,
mode=mode,
seed=seed,
deterministic_cudnn=deterministic_cudnn,
mp_ctx=mp_ctx,
deterministic_agents=deterministic_agents,
device=device,
worker_id=worker_id,
num_workers=num_workers,
distributed_port=distributed_port,
**kwargs,
)
self.enforce_expert = enforce_expert
def run_eval(
self,
checkpoint_file_path: str,
rollout_steps: int = 100,
visualizer: Optional[VizSuite] = None,
update_secs: float = 20.0,
verbose: bool = False,
) -> LoggingPackage:
assert self.actor_critic is not None, "called `run_eval` with no actor_critic"
# Sanity check that we haven't entered an invalid state. During eval the training_pipeline
# should be only set in this function and always unset at the end of it.
assert self.training_pipeline is None, (
"`training_pipeline` should be `None` before calling `run_eval`."
" This is necessary as we want to initialize new storages."
)
self.training_pipeline = self.config.training_pipeline()
ckpt = self.checkpoint_load(checkpoint_file_path, restart_pipeline=False)
total_steps = cast(int, ckpt["total_steps"])
eval_pipeline_stage = cast(
PipelineStage,
getattr(self.training_pipeline, f"{self.mode}_pipeline_stage"),
)
assert (
len(eval_pipeline_stage.stage_components) <= 1
), "Only one StageComponent is supported during inference."
uuid_to_storage = self.training_pipeline.get_stage_storage(eval_pipeline_stage)
assert len(uuid_to_storage) > 0, (
"No storage found for eval pipeline stage, this is a bug in AllenAct,"
" please submit an issue on GitHub (https://github.com/allenai/allenact/issues)."
)
uuid_to_rollout_storage = {
uuid: storage
for uuid, storage in uuid_to_storage.items()
if isinstance(storage, RolloutStorage)
}
uuid_to_non_rollout_storage = {
uuid: storage
for uuid, storage in uuid_to_storage.items()
if not isinstance(storage, RolloutStorage)
}
if len(uuid_to_rollout_storage) > 1 or len(uuid_to_non_rollout_storage) > 1:
raise NotImplementedError(
"Only one RolloutStorage and non-RolloutStorage object is allowed within an evaluation pipeline stage."
" If you'd like to evaluate against multiple storages please"
" submit an issue on GitHub (https://github.com/allenai/allenact/issues). For the moment you'll need"
" to evaluate against these storages separately."
)
rollout_storage = self.training_pipeline.rollout_storage
if visualizer is not None:
assert visualizer.empty()
num_paused = self.initialize_storage_and_viz(
storage_to_initialize=cast(
List[ExperienceStorage], list(uuid_to_storage.values())
),
visualizer=visualizer,
)
assert num_paused == 0, f"{num_paused} tasks paused when initializing eval"
if rollout_storage is not None:
num_tasks = sum(
self.vector_tasks.command(
"sampler_attr", ["length"] * self.num_active_samplers
)
) + ( # We need to add this as the first tasks have already been sampled
self.num_active_samplers
)
else:
num_tasks = 0
# get_logger().debug("worker {self.worker_id} number of tasks {num_tasks}")
steps = 0
self.actor_critic.eval()
last_time: float = time.time()
init_time: float = last_time
frames: int = 0
if verbose:
get_logger().info(
f"[{self.mode} worker {self.worker_id}] Running evaluation on {num_tasks} tasks"
f" for ckpt {checkpoint_file_path}"
)
if self.enforce_expert:
dist_wrapper_class = partial(
TeacherForcingDistr,
action_space=self.actor_critic.action_space,
num_active_samplers=None,
approx_steps=None,
teacher_forcing=None,
tracking_callback=None,
always_enforce=True,
)
else:
dist_wrapper_class = None
logging_pkg = LoggingPackage(
mode=self.mode,
training_steps=total_steps,
storage_uuid_to_total_experiences=self.training_pipeline.storage_uuid_to_total_experiences,
)
should_compute_onpolicy_losses = (
len(eval_pipeline_stage.loss_names) > 0
and eval_pipeline_stage.stage_components[0].storage_uuid
== self.training_pipeline.rollout_storage_uuid
)
while self.num_active_samplers > 0:
frames += self.num_active_samplers
num_newly_paused = self.collect_step_across_all_task_samplers(
rollout_storage_uuid=self.training_pipeline.rollout_storage_uuid,
uuid_to_storage=uuid_to_rollout_storage,
visualizer=visualizer,
dist_wrapper_class=dist_wrapper_class,
)
steps += 1
if should_compute_onpolicy_losses and num_newly_paused > 0:
# The `collect_step_across_all_task_samplers` method will automatically drop
# parts of the rollout storage that correspond to paused tasks (namely by calling"
# `rollout_storage.sampler_select(UNPAUSED_TASK_INDS)`). This makes sense when you don't need to
# compute losses for tasks but is a bit limiting here as we're throwing away data before
# using it to compute losses. As changing this is non-trivial we'll just warn the user
# for now.
get_logger().warning(
f"[{self.mode} worker {self.worker_id}] {num_newly_paused * rollout_storage.step} steps"
f" will be dropped when computing losses in evaluation. This is a limitation of the current"
f" implementation of rollout collection in AllenAct. If you'd like to see this"
f" functionality improved please submit an issue on GitHub"
f" (https://github.com/allenai/allenact/issues)."
)
if self.num_active_samplers == 0 or steps % rollout_steps == 0:
if should_compute_onpolicy_losses and self.num_active_samplers > 0:
with torch.no_grad():
actor_critic_output, _ = self.actor_critic(
**rollout_storage.agent_input_for_next_step()
)
before_update_info = dict(
next_value=actor_critic_output.values.detach(),
use_gae=eval_pipeline_stage.training_settings.use_gae,
gamma=eval_pipeline_stage.training_settings.gamma,
tau=eval_pipeline_stage.training_settings.gae_lambda,
adv_stats_callback=lambda advantages: {
"mean": advantages.mean(),
"std": advantages.std(),
},
)
# Prepare storage for iteration during loss computation
for storage in uuid_to_rollout_storage.values():
storage.before_updates(**before_update_info)
# Compute losses
with torch.no_grad():
for sc in eval_pipeline_stage.stage_components:
self.compute_losses_track_them_and_backprop(
stage=eval_pipeline_stage,
stage_component=sc,
storage=uuid_to_rollout_storage[sc.storage_uuid],
skip_backprop=True,
)
for storage in uuid_to_rollout_storage.values():
storage.after_updates()
cur_time = time.time()
if self.num_active_samplers == 0 or cur_time - last_time >= update_secs:
logging_pkg = self.aggregate_and_send_logging_package(
tracking_info_list=self.tracking_info_list,
logging_pkg=logging_pkg,
send_logging_package=False,
)
self.tracking_info_list.clear()
if verbose:
npending: int
lengths: List[int]
if self.num_active_samplers > 0:
lengths = self.vector_tasks.command(
"sampler_attr",
["length"] * self.num_active_samplers,
)
npending = sum(lengths)
else:
lengths = []
npending = 0
est_time_to_complete = (
"{:.2f}".format(
(
(cur_time - init_time)
* (npending / (num_tasks - npending))
/ 60
)
)
if npending != num_tasks
else "???"
)
get_logger().info(
f"[{self.mode} worker {self.worker_id}]"
f" For ckpt {checkpoint_file_path}"
f" {frames / (cur_time - init_time):.1f} fps,"
f" {npending}/{num_tasks} tasks pending ({lengths})."
f" ~{est_time_to_complete} min. to complete."
)
if logging_pkg.num_non_empty_metrics_dicts_added != 0:
get_logger().info(
", ".join(
[
f"[{self.mode} worker {self.worker_id}]"
f" num_{self.mode}_tasks_complete {logging_pkg.num_non_empty_metrics_dicts_added}",
*[
f"{k} {v:.3g}"
for k, v in logging_pkg.metrics_tracker.means().items()
],
*[
f"{k0[1]}/{k1} {v1:.3g}"
for k0, v0 in logging_pkg.info_trackers.items()
for k1, v1 in v0.means().items()
],
]
)
)
last_time = cur_time
get_logger().info(
f"[{self.mode} worker {self.worker_id}] Task evaluation complete, all task samplers paused."
)
if rollout_storage is not None:
self.vector_tasks.resume_all()
self.vector_tasks.set_seeds(self.worker_seeds(self.num_samplers, self.seed))
self.vector_tasks.reset_all()
logging_pkg = self.aggregate_and_send_logging_package(
tracking_info_list=self.tracking_info_list,
logging_pkg=logging_pkg,
send_logging_package=False,
)
self.tracking_info_list.clear()
logging_pkg.viz_data = (
visualizer.read_and_reset() if visualizer is not None else None
)
should_compute_offpolicy_losses = (
len(eval_pipeline_stage.loss_names) > 0
and not should_compute_onpolicy_losses
)
if should_compute_offpolicy_losses:
# In this case we are evaluating a non-rollout storage, e.g. some off-policy data
get_logger().info(
f"[{self.mode} worker {self.worker_id}] Non-rollout storage detected, will now compute losses"
f" using this storage."
)
offpolicy_eval_done = False
while not offpolicy_eval_done:
before_update_info = dict(
next_value=None,
use_gae=eval_pipeline_stage.training_settings.use_gae,
gamma=eval_pipeline_stage.training_settings.gamma,
tau=eval_pipeline_stage.training_settings.gae_lambda,
adv_stats_callback=lambda advantages: {
"mean": advantages.mean(),
"std": advantages.std(),
},
)
# Prepare storage for iteration during loss computation
for storage in uuid_to_non_rollout_storage.values():
storage.before_updates(**before_update_info)
# Compute losses
assert len(eval_pipeline_stage.stage_components) == 1
try:
for sc in eval_pipeline_stage.stage_components:
with torch.no_grad():
self.compute_losses_track_them_and_backprop(
stage=eval_pipeline_stage,
stage_component=sc,
storage=uuid_to_non_rollout_storage[sc.storage_uuid],
skip_backprop=True,
)
except EOFError:
offpolicy_eval_done = True
for storage in uuid_to_non_rollout_storage.values():
storage.after_updates()
total_bsize = sum(
tif.info.get("worker_batch_size", 0)
for tif in self.tracking_info_list
)
logging_pkg = self.aggregate_and_send_logging_package(
tracking_info_list=self.tracking_info_list,
logging_pkg=logging_pkg,
send_logging_package=False,
)
self.tracking_info_list.clear()
cur_time = time.time()
if verbose and (cur_time - last_time >= update_secs):
get_logger().info(
f"[{self.mode} worker {self.worker_id}]"
f" For ckpt {checkpoint_file_path}"
f" {total_bsize / (cur_time - init_time):.1f} its/sec."
)
if logging_pkg.info_trackers != 0:
get_logger().info(
", ".join(
[
f"[{self.mode} worker {self.worker_id}]"
f" num_{self.mode}_iters_complete {total_bsize}",
*[
f"{'/'.join(k0)}/{k1} {v1:.3g}"
for k0, v0 in logging_pkg.info_trackers.items()
for k1, v1 in v0.means().items()
],
]
)
)
last_time = cur_time
# Call after_updates here to reset all storages
for storage in uuid_to_storage.values():
storage.after_updates()
# Set the training pipeline to `None` so that the storages do not
# persist across calls to `run_eval`
self.training_pipeline = None
logging_pkg.checkpoint_file_name = checkpoint_file_path
return logging_pkg
@staticmethod
def skip_to_latest(checkpoints_queue: mp.Queue, command: Optional[str], data):
assert (
checkpoints_queue is not None
), "Attempting to process checkpoints queue but this queue is `None`."
cond = True
while cond:
sentinel = ("skip.AUTO.sentinel", time.time())
checkpoints_queue.put(
sentinel
) # valid since a single valid process is the only consumer
forwarded = False
while not forwarded:
new_command: Optional[str]
new_data: Any
(
new_command,
new_data,
) = checkpoints_queue.get() # block until next command arrives
if new_command == command:
data = new_data
elif new_command == sentinel[0]:
assert (
new_data == sentinel[1]
), f"Wrong sentinel found: {new_data} vs {sentinel[1]}"
forwarded = True
else:
raise ValueError(
f"Unexpected command {new_command} with data {new_data}"
)
time.sleep(1)
cond = not checkpoints_queue.empty()
return data
def process_checkpoints(self):
assert (
self.mode != TRAIN_MODE_STR
), "process_checkpoints only to be called from a valid or test instance"
assert (
self.checkpoints_queue is not None
), "Attempting to process checkpoints queue but this queue is `None`."
visualizer: Optional[VizSuite] = None
finalized = False
# noinspection PyBroadException
try:
while True:
command: Optional[str]
ckp_file_path: Any
(
command,
ckp_file_path,
) = self.checkpoints_queue.get() # block until first command arrives
# get_logger().debug(
# "{} {} command {} data {}".format(
# self.mode, self.worker_id, command, data
# )
# )
if command == "eval":
if self.mode == VALID_MODE_STR:
# skip to latest using
# 1. there's only consumer in valid
# 2. there's no quit/exit/close message issued by runner nor trainer
ckp_file_path = self.skip_to_latest(
checkpoints_queue=self.checkpoints_queue,
command=command,
data=ckp_file_path,
)
if (
visualizer is None
and self.machine_params.visualizer is not None
):
visualizer = self.machine_params.visualizer
eval_package = self.run_eval(
checkpoint_file_path=ckp_file_path,
visualizer=visualizer,
verbose=True,
update_secs=20 if self.mode == TEST_MODE_STR else 5 * 60,
)
self.results_queue.put(eval_package)
if self.is_distributed:
dist.barrier()
elif command in ["quit", "exit", "close"]:
finalized = True
break
else:
raise NotImplementedError()
except KeyboardInterrupt:
get_logger().info(
f"[{self.mode} worker {self.worker_id}] KeyboardInterrupt, exiting."
)
except Exception as e:
get_logger().error(
f"[{self.mode} worker {self.worker_id}] Encountered {type(e).__name__}, exiting."
)
get_logger().error(traceback.format_exc())
finally:
if finalized:
if self.mode == TEST_MODE_STR:
self.results_queue.put(("test_stopped", 0))
get_logger().info(
f"[{self.mode} worker {self.worker_id}] Complete, all checkpoints processed."
)
else:
if self.mode == TEST_MODE_STR:
self.results_queue.put(("test_stopped", self.worker_id + 1))
self.close(verbose=self.mode == TEST_MODE_STR)
================================================
FILE: allenact/algorithms/onpolicy_sync/losses/__init__.py
================================================
from .a2cacktr import A2C, ACKTR, A2CACKTR
from .ppo import PPO
================================================
FILE: allenact/algorithms/onpolicy_sync/losses/a2cacktr.py
================================================
"""Implementation of A2C and ACKTR losses."""
from typing import cast, Tuple, Dict, Optional
import torch
from allenact.algorithms.onpolicy_sync.losses.abstract_loss import (
AbstractActorCriticLoss,
ObservationType,
)
from allenact.base_abstractions.distributions import CategoricalDistr
from allenact.base_abstractions.misc import ActorCriticOutput
from allenact.utils.system import get_logger
class A2CACKTR(AbstractActorCriticLoss):
"""Class implementing A2C and ACKTR losses.
# Attributes
acktr : `True` if should use ACKTR loss (currently not supported), otherwise uses A2C loss.
value_loss_coef : Weight of value loss.
entropy_coef : Weight of entropy (encouraging) loss.
entropy_method_name : Name of Distr's entropy method name. Default is `entropy`,
but we might use `conditional_entropy` for `SequentialDistr`.
"""
def __init__(
self,
value_loss_coef,
entropy_coef,
acktr=False,
entropy_method_name: str = "entropy",
*args,
**kwargs,
):
"""Initializer.
See class documentation for parameter definitions.
"""
super().__init__(*args, **kwargs)
self.acktr = acktr
self.loss_key = "a2c_total" if not acktr else "aktr_total"
self.value_loss_coef = value_loss_coef
self.entropy_coef = entropy_coef
self.entropy_method_name = entropy_method_name
def loss_per_step( # type: ignore
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[CategoricalDistr],
) -> Dict[str, Tuple[torch.Tensor, Optional[float]]]:
actions = cast(torch.LongTensor, batch["actions"])
values = actor_critic_output.values
action_log_probs = actor_critic_output.distributions.log_prob(actions)
action_log_probs = action_log_probs.view(
action_log_probs.shape
+ (1,)
* (
len(cast(torch.Tensor, batch["adv_targ"]).shape)
- len(action_log_probs.shape)
)
)
dist_entropy: torch.FloatTensor = getattr(
actor_critic_output.distributions, self.entropy_method_name
)()
dist_entropy = dist_entropy.view(
dist_entropy.shape
+ ((1,) * (len(action_log_probs.shape) - len(dist_entropy.shape)))
)
value_loss = 0.5 * (cast(torch.FloatTensor, batch["returns"]) - values).pow(2)
# TODO: Decided not to use normalized advantages here,
# is this correct? (it's how it's done in Kostrikov's)
action_loss = -(
cast(torch.FloatTensor, batch["adv_targ"]).detach() * action_log_probs
)
if self.acktr:
# TODO: Currently acktr doesn't really work because of this natural gradient stuff
# that we should figure out how to integrate properly.
get_logger().warning("acktr is only partially supported.")
return {
"value": (value_loss, self.value_loss_coef),
"action": (action_loss, None),
"entropy": (dist_entropy.mul_(-1.0), self.entropy_coef), # type: ignore
}
def loss( # type: ignore
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[CategoricalDistr],
*args,
**kwargs,
):
losses_per_step = self.loss_per_step(
step_count=step_count,
batch=batch,
actor_critic_output=actor_critic_output,
)
losses = {
key: (loss.mean(), weight)
for (key, (loss, weight)) in losses_per_step.items()
}
total_loss = cast(
torch.Tensor,
sum(
loss * weight if weight is not None else loss
for loss, weight in losses.values()
),
)
return (
total_loss,
{
self.loss_key: total_loss.item(),
**{key: loss.item() for key, (loss, _) in losses.items()},
},
)
class A2C(A2CACKTR):
"""A2C Loss."""
def __init__(
self,
value_loss_coef,
entropy_coef,
entropy_method_name: str = "entropy",
*args,
**kwargs,
):
super().__init__(
value_loss_coef=value_loss_coef,
entropy_coef=entropy_coef,
acktr=False,
entropy_method_name=entropy_method_name,
*args,
**kwargs,
)
class ACKTR(A2CACKTR):
"""ACKTR Loss.
This code is not supported as it currently lacks an implementation
for recurrent models.
"""
def __init__(
self,
value_loss_coef,
entropy_coef,
entropy_method_name: str = "entropy",
*args,
**kwargs,
):
super().__init__(
value_loss_coef=value_loss_coef,
entropy_coef=entropy_coef,
acktr=True,
entropy_method_name=entropy_method_name,
*args,
**kwargs,
)
A2CConfig = dict(
value_loss_coef=0.5,
entropy_coef=0.01,
)
================================================
FILE: allenact/algorithms/onpolicy_sync/losses/abstract_loss.py
================================================
"""Defining abstract loss classes for actor critic models."""
import abc
from typing import Dict, Tuple, Union
import torch
from allenact.algorithms.onpolicy_sync.policy import ObservationType
from allenact.base_abstractions.distributions import CategoricalDistr
from allenact.base_abstractions.misc import Loss, ActorCriticOutput
class AbstractActorCriticLoss(Loss):
"""Abstract class representing a loss function used to train an
ActorCriticModel."""
# noinspection PyMethodOverriding
@abc.abstractmethod
def loss( # type: ignore
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[CategoricalDistr],
*args,
**kwargs,
) -> Union[
Tuple[torch.FloatTensor, Dict[str, float]],
Tuple[torch.FloatTensor, Dict[str, float], Dict[str, float]],
]:
"""Computes the loss.
# Parameters
batch : A batch of data corresponding to the information collected when rolling out (possibly many) agents
over a fixed number of steps. In particular this batch should have the same format as that returned by
`RolloutStorage.batched_experience_generator`.
actor_critic_output : The output of calling an ActorCriticModel on the observations in `batch`.
args : Extra args.
kwargs : Extra kwargs.
# Returns
A (0-dimensional) torch.FloatTensor corresponding to the computed loss. `.backward()` will be called on this
tensor in order to compute a gradient update to the ActorCriticModel's parameters.
A Dict[str, float] with scalar values corresponding to sub-losses.
An optional Dict[str, float] with scalar values corresponding to extra info to be processed per epoch and
combined across epochs by the engine.
"""
# TODO: The above documentation is missing what the batch dimensions are.
raise NotImplementedError()
================================================
FILE: allenact/algorithms/onpolicy_sync/losses/grouped_action_imitation.py
================================================
import functools
from typing import Dict, cast, Sequence, Set
import torch
from allenact.algorithms.onpolicy_sync.losses.abstract_loss import (
AbstractActorCriticLoss,
)
from allenact.algorithms.onpolicy_sync.policy import ObservationType
from allenact.base_abstractions.distributions import CategoricalDistr
from allenact.base_abstractions.misc import ActorCriticOutput
class GroupedActionImitation(AbstractActorCriticLoss):
def __init__(
self, nactions: int, action_groups: Sequence[Set[int]], *args, **kwargs
):
super().__init__(*args, **kwargs)
assert (
sum(len(ag) for ag in action_groups) == nactions
and len(functools.reduce(lambda x, y: x | y, action_groups)) == nactions
), f"`action_groups` (==`{action_groups}`) must be a partition of `[0, 1, 2, ..., nactions - 1]`"
self.nactions = nactions
self.action_groups_mask = torch.FloatTensor(
[
[i in action_group for i in range(nactions)]
for action_group in action_groups
]
+ [[1] * nactions] # type:ignore
)
def loss( # type: ignore
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[CategoricalDistr],
*args,
**kwargs,
):
observations = cast(Dict[str, torch.Tensor], batch["observations"])
assert "expert_group_action" in observations
expert_group_actions = observations["expert_group_action"]
# expert_group_actions = expert_group_actions + (expert_group_actions == -1).long() * (
# 1 + self.action_groups_mask.shape[0]
# )
if self.action_groups_mask.get_device() != expert_group_actions.get_device():
self.action_groups_mask = cast(
torch.FloatTensor,
self.action_groups_mask.cuda(expert_group_actions.get_device()),
)
expert_group_actions_reshaped = expert_group_actions.view(-1, 1)
expert_group_actions_mask = self.action_groups_mask[
expert_group_actions_reshaped
]
probs_tensor = actor_critic_output.distributions.probs_tensor
expert_group_actions_mask = expert_group_actions_mask.view(probs_tensor.shape)
total_loss = -(
torch.log((probs_tensor * expert_group_actions_mask).sum(-1))
).mean()
return total_loss, {
"grouped_action_cross_entropy": total_loss.item(),
}
================================================
FILE: allenact/algorithms/onpolicy_sync/losses/imitation.py
================================================
"""Defining imitation losses for actor critic type models."""
from collections import OrderedDict
from typing import Dict, cast, Optional, Union
import torch
import allenact.utils.spaces_utils as su
from allenact.algorithms.onpolicy_sync.losses.abstract_loss import (
AbstractActorCriticLoss,
ObservationType,
)
from allenact.base_abstractions.distributions import (
Distr,
CategoricalDistr,
SequentialDistr,
ConditionalDistr,
)
from allenact.base_abstractions.misc import ActorCriticOutput
from allenact.base_abstractions.sensor import AbstractExpertSensor
class Imitation(AbstractActorCriticLoss):
"""Expert imitation loss."""
def __init__(
self, expert_sensor: Optional[AbstractExpertSensor] = None, *args, **kwargs
):
super().__init__(*args, **kwargs)
self.expert_sensor = expert_sensor
@staticmethod
def group_loss(
distribution: Union[CategoricalDistr, ConditionalDistr],
expert_actions: torch.Tensor,
expert_actions_masks: torch.Tensor,
):
assert isinstance(distribution, CategoricalDistr) or (
isinstance(distribution, ConditionalDistr)
and isinstance(distribution.distr, CategoricalDistr)
), "This implementation only supports (groups of) `CategoricalDistr`"
expert_successes = expert_actions_masks.sum()
log_probs = distribution.log_prob(cast(torch.LongTensor, expert_actions))
assert (
log_probs.shape[: len(expert_actions_masks.shape)]
== expert_actions_masks.shape
)
# Add dimensions to `expert_actions_masks` on the right to allow for masking
# if necessary.
len_diff = len(log_probs.shape) - len(expert_actions_masks.shape)
assert len_diff >= 0
expert_actions_masks = expert_actions_masks.view(
*expert_actions_masks.shape, *((1,) * len_diff)
)
group_loss = -(expert_actions_masks * log_probs).sum() / torch.clamp(
expert_successes, min=1
)
return group_loss, expert_successes
def loss( # type: ignore
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[Distr],
*args,
**kwargs,
):
"""Computes the imitation loss.
# Parameters
batch : A batch of data corresponding to the information collected when rolling out (possibly many) agents
over a fixed number of steps. In particular this batch should have the same format as that returned by
`RolloutStorage.batched_experience_generator`.
Here `batch["observations"]` must contain `"expert_action"` observations
or `"expert_policy"` observations. See `ExpertActionSensor` (or `ExpertPolicySensor`) for an example of
a sensor producing such observations.
actor_critic_output : The output of calling an ActorCriticModel on the observations in `batch`.
args : Extra args. Ignored.
kwargs : Extra kwargs. Ignored.
# Returns
A (0-dimensional) torch.FloatTensor corresponding to the computed loss. `.backward()` will be called on this
tensor in order to compute a gradient update to the ActorCriticModel's parameters.
"""
observations = cast(Dict[str, torch.Tensor], batch["observations"])
losses = OrderedDict()
should_report_loss = False
if "expert_action" in observations:
if self.expert_sensor is None or not self.expert_sensor.use_groups:
expert_actions_and_mask = observations["expert_action"]
assert expert_actions_and_mask.shape[-1] == 2
expert_actions_and_mask_reshaped = expert_actions_and_mask.view(-1, 2)
expert_actions = expert_actions_and_mask_reshaped[:, 0].view(
*expert_actions_and_mask.shape[:-1], 1
)
expert_actions_masks = (
expert_actions_and_mask_reshaped[:, 1]
.float()
.view(*expert_actions_and_mask.shape[:-1], 1)
)
total_loss, expert_successes = self.group_loss(
cast(CategoricalDistr, actor_critic_output.distributions),
expert_actions,
expert_actions_masks,
)
should_report_loss = expert_successes.item() != 0
else:
expert_actions = su.unflatten(
self.expert_sensor.observation_space, observations["expert_action"]
)
total_loss = 0
ready_actions = OrderedDict()
for group_name, cd in zip(
self.expert_sensor.group_spaces,
cast(
SequentialDistr, actor_critic_output.distributions
).conditional_distrs,
):
assert group_name == cd.action_group_name
cd.reset()
cd.condition_on_input(**ready_actions)
expert_action = expert_actions[group_name][
AbstractExpertSensor.ACTION_POLICY_LABEL
]
expert_action_masks = expert_actions[group_name][
AbstractExpertSensor.EXPERT_SUCCESS_LABEL
]
ready_actions[group_name] = expert_action
current_loss, expert_successes = self.group_loss(
cd,
expert_action,
expert_action_masks,
)
should_report_loss = (
expert_successes.item() != 0 or should_report_loss
)
cd.reset()
if expert_successes.item() != 0:
losses[group_name + "_cross_entropy"] = current_loss.item()
total_loss = total_loss + current_loss
elif "expert_policy" in observations:
if self.expert_sensor is None or not self.expert_sensor.use_groups:
assert isinstance(
actor_critic_output.distributions, CategoricalDistr
), "This implementation currently only supports `CategoricalDistr`"
expert_policies = cast(Dict[str, torch.Tensor], batch["observations"])[
"expert_policy"
][..., :-1]
expert_actions_masks = cast(
Dict[str, torch.Tensor], batch["observations"]
)["expert_policy"][..., -1:]
expert_successes = expert_actions_masks.sum()
if expert_successes.item() > 0:
should_report_loss = True
log_probs = cast(
CategoricalDistr, actor_critic_output.distributions
).log_probs_tensor
# Add dimensions to `expert_actions_masks` on the right to allow for masking
# if necessary.
len_diff = len(log_probs.shape) - len(expert_actions_masks.shape)
assert len_diff >= 0
expert_actions_masks = expert_actions_masks.view(
*expert_actions_masks.shape, *((1,) * len_diff)
)
total_loss = (
-(log_probs * expert_policies) * expert_actions_masks
).sum() / torch.clamp(expert_successes, min=1)
else:
raise NotImplementedError(
"This implementation currently only supports `CategoricalDistr`"
)
else:
raise NotImplementedError(
"Imitation loss requires either `expert_action` or `expert_policy`"
" sensor to be active."
)
return (
total_loss,
(
{"expert_cross_entropy": total_loss.item(), **losses}
if should_report_loss
else {}
),
)
================================================
FILE: allenact/algorithms/onpolicy_sync/losses/ppo.py
================================================
"""Defining the PPO loss for actor critic type models."""
from typing import Dict, Optional, Callable, cast, Tuple
import torch
from allenact.algorithms.onpolicy_sync.losses.abstract_loss import (
AbstractActorCriticLoss,
ObservationType,
)
from allenact.base_abstractions.distributions import CategoricalDistr
from allenact.base_abstractions.misc import ActorCriticOutput
class PPO(AbstractActorCriticLoss):
"""Implementation of the Proximal Policy Optimization loss.
# Attributes
clip_param : The clipping parameter to use.
value_loss_coef : Weight of the value loss.
entropy_coef : Weight of the entropy (encouraging) loss.
use_clipped_value_loss : Whether or not to also clip the value loss.
clip_decay : Callable for clip param decay factor (function of the current number of steps)
entropy_method_name : Name of Distr's entropy method name. Default is `entropy`,
but we might use `conditional_entropy` for `SequentialDistr`
show_ratios : If True, adds tracking for the PPO ratio (linear, clamped, and used) in each
epoch to be logged by the engine.
normalize_advantage: Whether or not to use normalized advantage. Default is True.
"""
def __init__(
self,
clip_param: float,
value_loss_coef: float,
entropy_coef: float,
use_clipped_value_loss=True,
clip_decay: Optional[Callable[[int], float]] = None,
entropy_method_name: str = "entropy",
normalize_advantage: bool = True,
show_ratios: bool = False,
*args,
**kwargs
):
"""Initializer.
See the class documentation for parameter definitions.
"""
super().__init__(*args, **kwargs)
self.clip_param = clip_param
self.value_loss_coef = value_loss_coef
self.entropy_coef = entropy_coef
self.use_clipped_value_loss = use_clipped_value_loss
self.clip_decay = clip_decay if clip_decay is not None else (lambda x: 1.0)
self.entropy_method_name = entropy_method_name
self.show_ratios = show_ratios
if normalize_advantage:
self.adv_key = "norm_adv_targ"
else:
self.adv_key = "adv_targ"
def loss_per_step(
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[CategoricalDistr],
) -> Tuple[
Dict[str, Tuple[torch.Tensor, Optional[float]]], Dict[str, torch.Tensor]
]: # TODO tuple output
actions = cast(torch.LongTensor, batch["actions"])
values = actor_critic_output.values
action_log_probs = actor_critic_output.distributions.log_prob(actions)
dist_entropy: torch.FloatTensor = getattr(
actor_critic_output.distributions, self.entropy_method_name
)()
def add_trailing_dims(t: torch.Tensor):
assert len(t.shape) <= len(batch[self.adv_key].shape)
return t.view(
t.shape + ((1,) * (len(batch[self.adv_key].shape) - len(t.shape)))
)
dist_entropy = add_trailing_dims(dist_entropy)
clip_param = self.clip_param * self.clip_decay(step_count)
ratio = torch.exp(action_log_probs - batch["old_action_log_probs"])
ratio = add_trailing_dims(ratio)
clamped_ratio = torch.clamp(ratio, 1.0 - clip_param, 1.0 + clip_param)
surr1 = ratio * batch[self.adv_key]
surr2 = clamped_ratio * batch[self.adv_key]
use_clamped = surr2 < surr1
action_loss = -torch.where(cast(torch.Tensor, use_clamped), surr2, surr1)
if self.use_clipped_value_loss:
value_pred_clipped = batch["values"] + (values - batch["values"]).clamp(
-clip_param, clip_param
)
value_losses = (values - batch["returns"]).pow(2)
value_losses_clipped = (value_pred_clipped - batch["returns"]).pow(2)
value_loss = 0.5 * torch.max(value_losses, value_losses_clipped)
else:
value_loss = 0.5 * (cast(torch.FloatTensor, batch["returns"]) - values).pow(
2
)
# noinspection PyUnresolvedReferences
return (
{
"value": (value_loss, self.value_loss_coef),
"action": (action_loss, None),
"entropy": (dist_entropy.mul_(-1.0), self.entropy_coef), # type: ignore
},
(
{
"ratio": ratio,
"ratio_clamped": clamped_ratio,
"ratio_used": torch.where(
cast(torch.Tensor, use_clamped), clamped_ratio, ratio
),
}
if self.show_ratios
else {}
),
)
def loss( # type: ignore
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[CategoricalDistr],
*args,
**kwargs
):
losses_per_step, ratio_info = self.loss_per_step(
step_count=step_count,
batch=batch,
actor_critic_output=actor_critic_output,
)
losses = {
key: (loss.mean(), weight)
for (key, (loss, weight)) in losses_per_step.items()
}
total_loss = sum(
loss * weight if weight is not None else loss
for loss, weight in losses.values()
)
result = (
total_loss,
{
"ppo_total": cast(torch.Tensor, total_loss).item(),
**{key: loss.item() for key, (loss, _) in losses.items()},
},
{key: float(value.mean().item()) for key, value in ratio_info.items()},
)
return result if self.show_ratios else result[:2]
class PPOValue(AbstractActorCriticLoss):
"""Implementation of the Proximal Policy Optimization loss.
# Attributes
clip_param : The clipping parameter to use.
use_clipped_value_loss : Whether or not to also clip the value loss.
"""
def __init__(
self,
clip_param: float,
use_clipped_value_loss=True,
clip_decay: Optional[Callable[[int], float]] = None,
*args,
**kwargs
):
"""Initializer.
See the class documentation for parameter definitions.
"""
super().__init__(*args, **kwargs)
self.clip_param = clip_param
self.use_clipped_value_loss = use_clipped_value_loss
self.clip_decay = clip_decay if clip_decay is not None else (lambda x: 1.0)
def loss( # type: ignore
self,
step_count: int,
batch: ObservationType,
actor_critic_output: ActorCriticOutput[CategoricalDistr],
*args,
**kwargs
):
values = actor_critic_output.values
clip_param = self.clip_param * self.clip_decay(step_count)
if self.use_clipped_value_loss:
value_pred_clipped = batch["values"] + (values - batch["values"]).clamp(
-clip_param, clip_param
)
value_losses = (values - batch["returns"]).pow(2)
value_losses_clipped = (value_pred_clipped - batch["returns"]).pow(2)
value_loss = 0.5 * torch.max(value_losses, value_losses_clipped).mean()
else:
value_loss = (
0.5 * (cast(torch.FloatTensor, batch["returns"]) - values).pow(2).mean()
)
return (
value_loss,
{
"value": value_loss.item(),
},
)
PPOConfig = dict(clip_param=0.1, value_loss_coef=0.5, entropy_coef=0.01)
================================================
FILE: allenact/algorithms/onpolicy_sync/misc.py
================================================
from enum import Enum
from typing import Dict, Any, Optional
import attr
class TrackingInfoType(Enum):
LOSS = "loss"
TEACHER_FORCING = "teacher_forcing"
UPDATE_INFO = "update_info"
@attr.s(kw_only=True)
class TrackingInfo:
type: TrackingInfoType = attr.ib()
info: Dict[str, Any] = attr.ib()
n: int = attr.ib()
storage_uuid: Optional[str] = attr.ib()
stage_component_uuid: Optional[str] = attr.ib()
================================================
FILE: allenact/algorithms/onpolicy_sync/policy.py
================================================
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import abc
from collections import OrderedDict
from typing import TypeVar, Generic, Tuple, Optional, Union, Dict, List, Any
import gym
import torch
from gym.spaces.dict import Dict as SpaceDict
import torch.nn as nn
from allenact.base_abstractions.distributions import CategoricalDistr
from allenact.base_abstractions.misc import ActorCriticOutput, Memory
DistributionType = TypeVar("DistributionType")
MemoryDimType = Tuple[str, Optional[int]]
MemoryShapeType = Tuple[MemoryDimType, ...]
MemorySpecType = Tuple[MemoryShapeType, torch.dtype]
FullMemorySpecType = Dict[str, MemorySpecType]
ObservationType = Dict[str, Union[torch.Tensor, Dict[str, Any]]]
ActionType = Union[torch.Tensor, OrderedDict, Tuple, int]
class ActorCriticModel(Generic[DistributionType], nn.Module):
"""Abstract class defining a deep (recurrent) actor critic agent.
When defining a new agent, you should subclass this class and implement the abstract methods.
# Attributes
action_space : The space of actions available to the agent. This is of type `gym.spaces.Space`.
observation_space: The observation space expected by the agent. This is of type `gym.spaces.dict`.
"""
def __init__(self, action_space: gym.Space, observation_space: SpaceDict):
"""Initializer.
# Parameters
action_space : The space of actions available to the agent.
observation_space: The observation space expected by the agent.
"""
super().__init__()
self.action_space = action_space
self.observation_space = observation_space
self.memory_spec: Optional[List[Optional[FullMemorySpecType]]] = None
@property
def recurrent_memory_specification(self) -> Optional[FullMemorySpecType]:
"""The memory specification for the `ActorCriticModel`. See docs for
`_recurrent_memory_shape`
# Returns
The memory specification from `_recurrent_memory_shape`.
"""
if self.memory_spec is None:
self.memory_spec = [self._recurrent_memory_specification()]
spec = self.memory_spec[0]
if spec is None:
return None
for key in spec:
dims, _ = spec[key]
dim_names = [d[0] for d in dims]
assert (
"step" not in dim_names
), "`step` is automatically added and cannot be reused"
assert "sampler" in dim_names, "`sampler` dim must be defined"
return self.memory_spec[0]
@abc.abstractmethod
def _recurrent_memory_specification(self) -> Optional[FullMemorySpecType]:
"""Implementation of memory specification for the `ActorCriticModel`.
# Returns
If None, it indicates the model is memory-less.
Otherwise, it is a one-level dictionary (a map) with string keys (memory type identification) and
tuple values (memory type specification). Each specification tuple contains:
1. Memory type named shape, e.g.
`(("layer", 1), ("sampler", None), ("agent", 2), ("hidden", 32))`
for a two-agent GRU memory, where
the `sampler` dimension placeholder *always* precedes the optional `agent` dimension;
the optional `agent` dimension has the number of agents in the model and is *always* the one after
`sampler` if present;
and `layer` and `hidden` correspond to the standard RNN hidden state parametrization.
2. The data type, e.g. `torch.float32`.
The `sampler` dimension placeholder is mandatory for all memories.
For a single-agent ActorCritic model it is often more convenient to skip the agent dimension, e.g.
`(("layer", 1), ("sampler", None), ("hidden", 32))` for a GRU memory.
"""
raise NotImplementedError()
@abc.abstractmethod
def forward( # type:ignore
self,
observations: ObservationType,
memory: Memory,
prev_actions: ActionType,
masks: torch.FloatTensor,
) -> Tuple[ActorCriticOutput[DistributionType], Optional[Memory]]:
"""Transforms input observations (& previous hidden state) into action
probabilities and the state value.
# Parameters
observations : Multi-level map from key strings to tensors of shape [steps, samplers, (agents,) ...] with the
current observations.
memory : `Memory` object with recurrent memory. The shape of each tensor is determined by the corresponding
entry in `_recurrent_memory_specification`.
prev_actions : ActionType with tensors of shape [steps, samplers, ...] with the previous actions.
masks : tensor of shape [steps, samplers, agents, 1] with zeros indicating steps where a new episode/task
starts.
# Returns
A tuple whose first element is an object of class ActorCriticOutput which stores
the agents' probability distribution over possible actions (shape [steps, samplers, ...]),
the agents' value for the state (shape [steps, samplers, ..., 1]), and any extra information needed for
loss computations. The second element is an optional `Memory`, which is only used in models with recurrent
memory.
"""
raise NotImplementedError()
class LinearActorCriticHead(nn.Module):
def __init__(self, input_size: int, num_actions: int):
super().__init__()
self.input_size = input_size
self.num_actions = num_actions
self.actor_and_critic = nn.Linear(input_size, 1 + num_actions)
nn.init.orthogonal_(self.actor_and_critic.weight)
nn.init.constant_(self.actor_and_critic.bias, 0)
def forward(self, x) -> Tuple[CategoricalDistr, torch.Tensor]:
out = self.actor_and_critic(x)
logits = out[..., :-1]
values = out[..., -1:]
# noinspection PyArgumentList
return (
# logits are [step, sampler, ...]
CategoricalDistr(logits=logits),
# values are [step, sampler, flattened]
values.view(*values.shape[:2], -1),
)
class LinearCriticHead(nn.Module):
def __init__(self, input_size: int):
super().__init__()
self.fc = nn.Linear(input_size, 1)
nn.init.orthogonal_(self.fc.weight)
nn.init.constant_(self.fc.bias, 0)
def forward(self, x):
return self.fc(x).view(*x.shape[:2], -1) # [steps, samplers, flattened]
class LinearActorHead(nn.Module):
def __init__(self, num_inputs: int, num_outputs: int):
super().__init__()
self.linear = nn.Linear(num_inputs, num_outputs)
nn.init.orthogonal_(self.linear.weight, gain=0.01)
nn.init.constant_(self.linear.bias, 0)
def forward(self, x: torch.FloatTensor): # type: ignore
x = self.linear(x) # type:ignore
# noinspection PyArgumentList
return CategoricalDistr(logits=x) # logits are [step, sampler, ...]
================================================
FILE: allenact/algorithms/onpolicy_sync/runner.py
================================================
"""Defines the reinforcement learning `OnPolicyRunner`."""
import copy
import enum
import glob
import importlib.util
import inspect
import itertools
import json
import math
import os
import pathlib
import queue
import random
import signal
import subprocess
import sys
import time
import traceback
from collections import defaultdict
from multiprocessing.context import BaseContext
from multiprocessing.process import BaseProcess
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union, Set
import filelock
import numpy as np
import torch
import torch.multiprocessing as mp
from setproctitle import setproctitle as ptitle
from torch.distributions.utils import lazy_property
from allenact.algorithms.onpolicy_sync.engine import (
TEST_MODE_STR,
TRAIN_MODE_STR,
VALID_MODE_STR,
OnPolicyInference,
OnPolicyRLEngine,
OnPolicyTrainer,
)
from allenact.base_abstractions.callbacks import Callback
from allenact.base_abstractions.experiment_config import ExperimentConfig, MachineParams
from allenact.base_abstractions.sensor import Sensor
from allenact.utils.experiment_utils import (
LoggingPackage,
ScalarMeanTracker,
set_deterministic_cudnn,
set_seed,
download_checkpoint_from_wandb,
)
from allenact.utils.misc_utils import (
NumpyJSONEncoder,
all_equal,
get_git_diff_of_project,
)
from allenact.utils.model_utils import md5_hash_of_state_dict
from allenact.utils.system import find_free_port, get_logger
from allenact.utils.tensor_utils import SummaryWriter
from allenact.utils.viz_utils import VizSuite
CONFIG_KWARGS_STR = "__CONFIG_KWARGS__"
class SaveDirFormat(enum.Enum):
"""Directory formats that can be used when saving tensorboard logs,
checkpoints, etc.
during training/evaluation.
FLAT: the first-level directories are logs, checkpoints, metrics, etc; the second-level are time strings of each experiment
NESTED: the opposite to FLAT.
"""
FLAT = "FLAT"
NESTED = "NESTED"
# Has results queue (aggregated per trainer), checkpoints queue and mp context
# Instantiates train, validate, and test workers
# Logging
# Saves configs, makes folder for trainer models
class OnPolicyRunner(object):
def __init__(
self,
config: ExperimentConfig,
output_dir: str,
loaded_config_src_files: Optional[Dict[str, str]],
seed: Optional[int] = None,
mode: str = "train",
deterministic_cudnn: bool = False,
deterministic_agents: bool = False,
mp_ctx: Optional[BaseContext] = None,
multiprocessing_start_method: str = "default",
extra_tag: str = "",
disable_tensorboard: bool = False,
disable_config_saving: bool = False,
distributed_ip_and_port: str = "127.0.0.1:0",
distributed_preemption_threshold: float = 0.7,
machine_id: int = 0,
save_dir_fmt: SaveDirFormat = SaveDirFormat.FLAT,
callbacks_paths: Optional[str] = None,
):
self.config = config
self.output_dir = output_dir
self.loaded_config_src_files = loaded_config_src_files
self.seed = seed if seed is not None else random.randint(0, 2**31 - 1)
self.deterministic_cudnn = deterministic_cudnn
self.distributed_preemption_threshold = distributed_preemption_threshold
if multiprocessing_start_method == "default":
if torch.cuda.is_available():
multiprocessing_start_method = "forkserver"
else:
# Spawn seems to play nicer with cpus and debugging
multiprocessing_start_method = "spawn"
self.mp_ctx = self.init_context(mp_ctx, multiprocessing_start_method)
self.extra_tag = extra_tag
self.mode = mode.lower().strip()
self.visualizer: Optional[VizSuite] = None
self.deterministic_agents = deterministic_agents
self.disable_tensorboard = disable_tensorboard
self.disable_config_saving = disable_config_saving
assert self.mode in [
TRAIN_MODE_STR,
TEST_MODE_STR,
], "Only 'train' and 'test' modes supported in runner"
if self.deterministic_cudnn:
set_deterministic_cudnn()
set_seed(self.seed)
self.queues: Optional[Dict[str, mp.Queue]] = None
self.processes: Dict[str, List[Union[BaseProcess, mp.Process]]] = defaultdict(
list
)
self.current_checkpoint = None
self._local_start_time_str: Optional[str] = None
self._is_closed: bool = False
self._collect_valid_results: bool = False
self.distributed_ip_and_port = distributed_ip_and_port
self.machine_id = machine_id
self.save_dir_fmt = save_dir_fmt
self.callbacks_paths = callbacks_paths
@lazy_property
def callbacks(self):
return self.setup_callback_classes(self.callbacks_paths)
@property
def local_start_time_str(self) -> str:
if self._local_start_time_str is None:
raise RuntimeError(
"Local start time string does not exist as neither `start_train()` or `start_test()`"
" has been called on this runner."
)
return self._local_start_time_str
@property
def running_validation(self):
pipeline = self.config.training_pipeline()
return (
sum(
MachineParams.instance_from(
self.config.machine_params(VALID_MODE_STR)
).nprocesses
)
> 0
or (
pipeline.rollout_storage_uuid is None
and len(pipeline.valid_pipeline_stage.loss_names) > 0
)
) and self.machine_id == 0
@staticmethod
def init_context(
mp_ctx: Optional[BaseContext] = None,
multiprocessing_start_method: str = "forkserver",
valid_start_methods: Tuple[str, ...] = ("forkserver", "spawn", "fork"),
):
if mp_ctx is None:
assert multiprocessing_start_method in valid_start_methods, (
f"multiprocessing_start_method must be one of {valid_start_methods}."
f" Got '{multiprocessing_start_method}'"
)
mp_ctx = mp.get_context(multiprocessing_start_method)
elif multiprocessing_start_method != mp_ctx.get_start_method():
get_logger().warning(
f"ignoring multiprocessing_start_method '{multiprocessing_start_method}'"
f" and using given context with '{mp_ctx.get_start_method()}'"
)
return mp_ctx
def setup_callback_classes(self, callbacks: Optional[str]) -> Set[Callback]:
"""Get a list of Callback classes from a comma-separated list of files,
paths, and/or functions.
After separating the `callbacks` into a list of strings, each string should either
be a:
1. Name of a function defined on the experiment config that, when called, returns an
object with of type `Callback`.
2. Path to a python file containing a single class that inherits from `Callback`.
3. Module path (e.g. `path.to.module`) where this module contains a single class that
inherits from `Callback`.
"""
if callbacks == "" or callbacks is None:
return set()
setup_dict = dict(
name=f"{self.experiment_name}/{self.local_start_time_str}",
config=self.config,
mode=self.mode,
)
callback_objects = set()
files = callbacks.split(",")
for filename in files:
# Check if the `filename` is a function on the config
if not any(k in filename for k in [".", "/"]):
callback_func = getattr(self.config, filename, None)
if callback_func is not None:
callback = callback_func()
callback.setup(**setup_dict)
callback_objects.add(callback)
continue
# Otherwise find the Callback class in the file or module
module_path = filename.replace("/", ".")
if module_path.endswith(".py"):
module_path = module_path[:-3]
module = importlib.import_module(module_path)
classes = inspect.getmembers(module, inspect.isclass)
callback_classes = [
mod_class[1]
for mod_class in classes
if issubclass(mod_class[1], Callback)
]
assert callback_classes == 1, (
f"Expected a single callback class in {filename}, but found {len(callback_classes)}."
f" These classes were found: {callback_classes}."
)
for mod_class in callback_classes:
# NOTE: initialize the callback class
callback = mod_class[1]()
callback.setup(**setup_dict)
callback_objects.add(callback)
return callback_objects
def _acquire_unique_local_start_time_string(self) -> str:
"""Creates a (unique) local start time string for this experiment.
Ensures through file locks that the local start time string
produced is unique. This implies that, if one has many
experiments starting in parallel, at most one will be started
every second (as the local start time string only records the
time up to the current second).
"""
os.makedirs(self.output_dir, exist_ok=True)
start_time_string_lock_path = os.path.abspath(
os.path.join(self.output_dir, ".allenact_start_time_string.lock")
)
try:
with filelock.FileLock(start_time_string_lock_path, timeout=60):
last_start_time_string_path = os.path.join(
self.output_dir, ".allenact_last_start_time_string"
)
pathlib.Path(last_start_time_string_path).touch()
with open(last_start_time_string_path, "r") as f:
last_start_time_string_list = f.readlines()
while True:
candidate_str = time.strftime(
"%Y-%m-%d_%H-%M-%S", time.localtime(time.time())
)
if (
len(last_start_time_string_list) == 0
or last_start_time_string_list[0].strip() != candidate_str
):
break
time.sleep(0.2)
with open(last_start_time_string_path, "w") as f:
f.write(candidate_str)
except filelock.Timeout as e:
get_logger().exception(
f"Could not acquire the lock for {start_time_string_lock_path} for 60 seconds,"
" this suggests an unexpected deadlock. Please close all AllenAct training processes,"
" delete this lockfile, and try again."
)
raise e
assert candidate_str is not None
return candidate_str
def worker_devices(self, mode: str):
machine_params: MachineParams = MachineParams.instance_from(
self.config.machine_params(mode)
)
devices = machine_params.devices
assert all_equal(devices) or all(
d.index >= 0 for d in devices
), f"Cannot have a mix of CPU and GPU devices (`devices == {devices}`)"
get_logger().info(f"Using {len(devices)} {mode} workers on devices {devices}")
return devices
def local_worker_ids(self, mode: str):
machine_params: MachineParams = MachineParams.instance_from(
self.config.machine_params(mode, machine_id=self.machine_id)
)
ids = machine_params.local_worker_ids
get_logger().info(
f"Using local worker ids {ids} (total {len(ids)} workers in machine {self.machine_id})"
)
return ids
def init_visualizer(self, mode: str):
if not self.disable_tensorboard:
# Note: Avoid instantiating anything in machine_params (use Builder if needed)
machine_params = MachineParams.instance_from(
self.config.machine_params(mode)
)
self.visualizer = machine_params.visualizer
@staticmethod
def init_process(mode: str, id: int, to_close_on_termination: OnPolicyRLEngine):
ptitle(f"{mode}-{id}")
def create_handler(termination_type: str):
def handler(_signo, _frame):
prefix = f"{termination_type} signal sent to worker {mode}-{id}."
if to_close_on_termination.is_closed:
get_logger().info(
f"{prefix} Worker {mode}-{id} is already closed, exiting."
)
sys.exit(0)
elif not to_close_on_termination.is_closing:
get_logger().info(
f"{prefix} Forcing worker {mode}-{id} to close and exiting."
)
# noinspection PyBroadException
try:
to_close_on_termination.close(True)
except Exception:
get_logger().error(
f"Error occurred when closing the RL engine used by work {mode}-{id}."
f" We cannot recover from this and will simply exit. The exception:\n"
f"{traceback.format_exc()}"
)
sys.exit(1)
sys.exit(0)
else:
get_logger().info(
f"{prefix} Worker {mode}-{id} is already closing, ignoring this signal."
)
return handler
signal.signal(signal.SIGTERM, create_handler("Termination"))
signal.signal(signal.SIGINT, create_handler("Interrupt"))
@staticmethod
def init_worker(engine_class, args, kwargs):
mode = kwargs["mode"]
id = kwargs["worker_id"]
worker = None
try:
worker = engine_class(*args, **kwargs)
except Exception:
get_logger().error(f"Encountered Exception. Terminating {mode} worker {id}")
get_logger().exception(traceback.format_exc())
kwargs["results_queue"].put((f"{mode}_stopped", 1 + id))
finally:
return worker
@lazy_property
def _get_callback_sensors(self) -> List[Sensor]:
callback_sensors: List[Sensor] = []
for c in self.callbacks:
sensors = c.callback_sensors()
if sensors is not None:
callback_sensors.extend(sensors)
return callback_sensors
@staticmethod
def train_loop(
id: int = 0,
checkpoint: Optional[str] = None,
restart_pipeline: bool = False,
valid_on_initial_weights: bool = False,
*engine_args,
**engine_kwargs,
):
engine_kwargs["mode"] = TRAIN_MODE_STR
engine_kwargs["worker_id"] = id
engine_kwargs_for_print = {
k: (v if k != "initial_model_state_dict" else "[SUPPRESSED]")
for k, v in engine_kwargs.items()
}
get_logger().info(f"train {id} args {engine_kwargs_for_print}")
trainer: OnPolicyTrainer = OnPolicyRunner.init_worker(
engine_class=OnPolicyTrainer, args=engine_args, kwargs=engine_kwargs
)
if trainer is not None:
OnPolicyRunner.init_process("Train", id, to_close_on_termination=trainer)
trainer.train(
checkpoint_file_name=checkpoint,
restart_pipeline=restart_pipeline,
valid_on_initial_weights=valid_on_initial_weights,
)
@staticmethod
def valid_loop(id: int = 0, *engine_args, **engine_kwargs):
engine_kwargs["mode"] = VALID_MODE_STR
engine_kwargs["worker_id"] = id
get_logger().info(f"valid {id} args {engine_kwargs}")
valid = OnPolicyRunner.init_worker(
engine_class=OnPolicyInference, args=engine_args, kwargs=engine_kwargs
)
if valid is not None:
OnPolicyRunner.init_process("Valid", id, to_close_on_termination=valid)
valid.process_checkpoints() # gets checkpoints via queue
@staticmethod
def test_loop(id: int = 0, *engine_args, **engine_kwargs):
engine_kwargs["mode"] = TEST_MODE_STR
engine_kwargs["worker_id"] = id
get_logger().info(f"test {id} args {engine_kwargs}")
test = OnPolicyRunner.init_worker(OnPolicyInference, engine_args, engine_kwargs)
if test is not None:
OnPolicyRunner.init_process("Test", id, to_close_on_termination=test)
test.process_checkpoints() # gets checkpoints via queue
def _initialize_start_train_or_start_test(self):
self._is_closed = False
if self.queues is not None:
for k, q in self.queues.items():
try:
out = q.get(timeout=1)
raise RuntimeError(
f"{k} queue was not empty before starting new training/testing (contained {out})."
f" This should not happen, please report how you obtained this error"
f" by creating an issue at https://github.com/allenai/allenact/issues."
)
except queue.Empty:
pass
self.queues = {
"results": self.mp_ctx.Queue(),
"checkpoints": self.mp_ctx.Queue(),
}
self._local_start_time_str = self._acquire_unique_local_start_time_string()
def get_port(self):
passed_port = int(self.distributed_ip_and_port.split(":")[1])
if passed_port == 0:
assert (
self.machine_id == 0
), "Only runner with `machine_id` == 0 can search for a free port."
distributed_port = find_free_port(
self.distributed_ip_and_port.split(":")[0]
)
else:
distributed_port = passed_port
get_logger().info(
f"Engines on machine_id == {self.machine_id} using port {distributed_port} and seed {self.seed}"
)
return distributed_port
def start_train(
self,
checkpoint: Optional[str] = None,
restart_pipeline: bool = False,
max_sampler_processes_per_worker: Optional[int] = None,
save_ckpt_after_every_pipeline_stage: bool = True,
collect_valid_results: bool = False,
valid_on_initial_weights: bool = False,
try_restart_after_task_error: bool = False,
save_ckpt_at_every_host: bool = False,
):
self._initialize_start_train_or_start_test()
self._collect_valid_results = collect_valid_results
if not self.disable_config_saving:
self.save_project_state()
devices = self.worker_devices(TRAIN_MODE_STR)
num_workers = len(devices)
# Be extra careful to ensure that all models start
# with the same initializations.
set_seed(self.seed)
initial_model_state_dict = self.config.create_model(
sensor_preprocessor_graph=MachineParams.instance_from(
self.config.machine_params(self.mode)
).sensor_preprocessor_graph
).state_dict()
distributed_port = 0 if num_workers == 1 else self.get_port()
if (
num_workers > 1
and "NCCL_ASYNC_ERROR_HANDLING" not in os.environ
and "NCCL_BLOCKING_WAIT" not in os.environ
):
# This ensures the NCCL distributed backend will throw errors
# if we timeout at a call to `barrier()`
os.environ["NCCL_ASYNC_ERROR_HANDLING"] = "1"
worker_ids = self.local_worker_ids(TRAIN_MODE_STR)
if checkpoint is not None:
if checkpoint[:8] == "wandb://":
ckpt_dir = "/tmp/wandb_ckpts"
os.makedirs(ckpt_dir, exist_ok=True)
checkpoint = download_checkpoint_from_wandb(
checkpoint, ckpt_dir, only_allow_one_ckpt=True
)
model_hash = None
for trainer_id in worker_ids:
training_kwargs = dict(
id=trainer_id,
checkpoint=checkpoint,
restart_pipeline=restart_pipeline,
experiment_name=self.experiment_name,
config=self.config,
callback_sensors=self._get_callback_sensors,
results_queue=self.queues["results"],
checkpoints_queue=(
self.queues["checkpoints"] if self.running_validation else None
),
checkpoints_dir=self.checkpoint_dir(),
seed=self.seed,
deterministic_cudnn=self.deterministic_cudnn,
mp_ctx=self.mp_ctx,
num_workers=num_workers,
device=devices[trainer_id],
distributed_ip=self.distributed_ip_and_port.split(":")[0],
distributed_port=distributed_port,
max_sampler_processes_per_worker=max_sampler_processes_per_worker,
save_ckpt_after_every_pipeline_stage=save_ckpt_after_every_pipeline_stage,
initial_model_state_dict=(
initial_model_state_dict if model_hash is None else model_hash
),
first_local_worker_id=worker_ids[0],
distributed_preemption_threshold=self.distributed_preemption_threshold,
valid_on_initial_weights=valid_on_initial_weights,
try_restart_after_task_error=try_restart_after_task_error,
save_ckpt_at_every_host=save_ckpt_at_every_host,
)
train: BaseProcess = self.mp_ctx.Process(
target=self.train_loop,
kwargs=training_kwargs,
)
try:
train.start()
except (ValueError, OSError, ConnectionRefusedError, EOFError) as e:
# If the `initial_model_state_dict` is too large we sometimes
# run into errors passing it with multiprocessing. In such cases
# we instead hash the state_dict and confirm, in each engine worker, that
# this hash equals the model the engine worker instantiates.
if (
(isinstance(e, ValueError) and e.args[0] == "too many fds")
or (isinstance(e, OSError) and e.errno == 22)
or (isinstance(e, ConnectionRefusedError) and e.errno == 111)
or isinstance(e, EOFError)
):
model_hash = md5_hash_of_state_dict(initial_model_state_dict)
training_kwargs["initial_model_state_dict"] = model_hash
train = self.mp_ctx.Process(
target=self.train_loop,
kwargs=training_kwargs,
)
train.start()
else:
raise e
self.processes[TRAIN_MODE_STR].append(train)
get_logger().info(
f"Started {len(self.processes[TRAIN_MODE_STR])} train processes"
)
# Validation
if self.running_validation:
device = self.worker_devices(VALID_MODE_STR)[0]
self.init_visualizer(VALID_MODE_STR)
valid: BaseProcess = self.mp_ctx.Process(
target=self.valid_loop,
args=(0,),
kwargs=dict(
config=self.config,
callback_sensors=self._get_callback_sensors,
results_queue=self.queues["results"],
checkpoints_queue=self.queues["checkpoints"],
seed=12345, # TODO allow same order for randomly sampled tasks? Is this any useful anyway?
deterministic_cudnn=self.deterministic_cudnn,
deterministic_agents=self.deterministic_agents,
mp_ctx=self.mp_ctx,
device=device,
max_sampler_processes_per_worker=max_sampler_processes_per_worker,
),
)
valid.start()
self.processes[VALID_MODE_STR].append(valid)
get_logger().info(
f"Started {len(self.processes[VALID_MODE_STR])} valid processes"
)
else:
get_logger().info(
"No processes allocated to validation, no validation will be run."
)
metrics_file_template: Optional[str] = None
if self._collect_valid_results:
metrics_dir = self.metric_path(self.local_start_time_str)
os.makedirs(metrics_dir, exist_ok=True)
suffix = f"__valid_{self.local_start_time_str}"
metrics_file_template = os.path.join(
metrics_dir, "metrics" + suffix + "{:012d}.json"
) # template for training steps
get_logger().info(
f"Saving valid metrics with template {metrics_file_template}"
)
# Check output file can be written
with open(metrics_file_template.format(0), "w") as f:
json.dump([], f, indent=4, sort_keys=True, cls=NumpyJSONEncoder)
valid_results = self.log_and_close(
start_time_str=self.local_start_time_str,
nworkers=len(worker_ids), # TODO num_workers once we forward metrics,
metrics_file=metrics_file_template,
)
if not self._collect_valid_results:
return self.local_start_time_str
else:
return self.local_start_time_str, valid_results
def start_test(
self,
checkpoint_path_dir_or_pattern: str,
infer_output_dir: bool = False,
approx_ckpt_step_interval: Optional[Union[float, int]] = None,
max_sampler_processes_per_worker: Optional[int] = None,
inference_expert: bool = False,
) -> List[Dict]:
# Tester always runs on a single machine
assert (
self.machine_id == 0
), f"Received `machine_id={self.machine_id} for test. Only one machine supported."
assert isinstance(
checkpoint_path_dir_or_pattern, str
), "Must provide a --checkpoint path or pattern to test on."
self.extra_tag += (
"__" * (len(self.extra_tag) > 0) + "enforced_test_expert"
) * inference_expert
self._initialize_start_train_or_start_test()
devices = self.worker_devices(TEST_MODE_STR)
self.init_visualizer(TEST_MODE_STR)
num_testers = len(devices)
distributed_port = 0
if num_testers > 1:
distributed_port = find_free_port()
# Tester always runs on a single machine
for tester_it in range(num_testers):
test: BaseProcess = self.mp_ctx.Process(
target=self.test_loop,
args=(tester_it,),
kwargs=dict(
config=self.config,
callback_sensors=self._get_callback_sensors,
results_queue=self.queues["results"],
checkpoints_queue=self.queues["checkpoints"],
seed=12345, # TODO allow same order for randomly sampled tasks? Is this any useful anyway?
deterministic_cudnn=self.deterministic_cudnn,
deterministic_agents=self.deterministic_agents,
mp_ctx=self.mp_ctx,
num_workers=num_testers,
device=devices[tester_it],
max_sampler_processes_per_worker=max_sampler_processes_per_worker,
distributed_port=distributed_port,
enforce_expert=inference_expert,
),
)
test.start()
self.processes[TEST_MODE_STR].append(test)
get_logger().info(
f"Started {len(self.processes[TEST_MODE_STR])} test processes"
)
checkpoint_paths = self.get_checkpoint_files(
checkpoint_path_dir_or_pattern=checkpoint_path_dir_or_pattern,
approx_ckpt_step_interval=approx_ckpt_step_interval,
)
steps = [self.step_from_checkpoint(cp) for cp in checkpoint_paths]
get_logger().info(f"Running test on {len(steps)} steps {steps}")
for checkpoint_path in checkpoint_paths:
# Make all testers work on each checkpoint
for tester_it in range(num_testers):
self.queues["checkpoints"].put(("eval", checkpoint_path))
# Signal all testers to terminate cleanly
for _ in range(num_testers):
self.queues["checkpoints"].put(("quit", None))
if self.save_dir_fmt == SaveDirFormat.NESTED:
if infer_output_dir: # NOTE: we change output_dir here
self.output_dir = self.checkpoint_log_folder_str(checkpoint_paths[0])
suffix = ""
elif self.save_dir_fmt == SaveDirFormat.FLAT:
suffix = f"__test_{self.local_start_time_str}"
else:
raise NotImplementedError
metrics_dir = self.metric_path(self.local_start_time_str)
os.makedirs(metrics_dir, exist_ok=True)
metrics_file_path = os.path.join(metrics_dir, "metrics" + suffix + ".json")
get_logger().info(f"Saving test metrics in {metrics_file_path}")
# Check output file can be written
with open(metrics_file_path, "w") as f:
json.dump([], f, indent=4, sort_keys=True, cls=NumpyJSONEncoder)
return self.log_and_close(
start_time_str=self.checkpoint_start_time_str(checkpoint_paths[0]),
nworkers=num_testers,
test_steps=steps,
metrics_file=metrics_file_path,
)
@staticmethod
def checkpoint_start_time_str(checkpoint_file_name):
parts = checkpoint_file_name.split(os.path.sep)
assert len(parts) > 1, f"{checkpoint_file_name} is not a valid checkpoint path"
start_time_str = parts[-2]
get_logger().info(f"Using checkpoint start time {start_time_str}")
return start_time_str
@staticmethod
def checkpoint_log_folder_str(checkpoint_file_name):
parts = checkpoint_file_name.split(os.path.sep)
assert len(parts) > 1, f"{checkpoint_file_name} is not a valid checkpoint path"
log_folder_str = os.path.sep.join(parts[:-2]) # remove checkpoints/*.pt
get_logger().info(f"Using log folder {log_folder_str}")
return log_folder_str
@property
def experiment_name(self):
if len(self.extra_tag) > 0:
return f"{self.config.tag()}_{self.extra_tag}"
return self.config.tag()
def checkpoint_dir(
self, start_time_str: Optional[str] = None, create_if_none: bool = True
):
path_parts = [
(
self.config.tag()
if self.extra_tag == ""
else os.path.join(self.config.tag(), self.extra_tag)
),
start_time_str or self.local_start_time_str,
]
if self.save_dir_fmt == SaveDirFormat.NESTED:
folder = os.path.join(
self.output_dir,
*path_parts,
"checkpoints",
)
elif self.save_dir_fmt == SaveDirFormat.FLAT:
folder = os.path.join(
self.output_dir,
"checkpoints",
*path_parts,
)
else:
raise NotImplementedError
if create_if_none:
os.makedirs(folder, exist_ok=True)
return folder
def log_writer_path(self, start_time_str: str) -> str:
if self.save_dir_fmt == SaveDirFormat.NESTED:
if self.mode == TEST_MODE_STR:
return os.path.join(
self.output_dir,
"test",
self.config.tag(),
self.local_start_time_str,
)
path = os.path.join(
self.output_dir,
(
self.config.tag()
if self.extra_tag == ""
else os.path.join(self.config.tag(), self.extra_tag)
),
start_time_str,
"train_tb",
)
return path
elif self.save_dir_fmt == SaveDirFormat.FLAT:
path = os.path.join(
self.output_dir,
"tb",
(
self.config.tag()
if self.extra_tag == ""
else os.path.join(self.config.tag(), self.extra_tag)
),
start_time_str,
)
if self.mode == TEST_MODE_STR:
path = os.path.join(path, "test", self.local_start_time_str)
return path
else:
raise NotImplementedError
def metric_path(self, start_time_str: str) -> str:
if self.save_dir_fmt == SaveDirFormat.NESTED:
return os.path.join(
self.output_dir,
"test",
self.config.tag(),
start_time_str,
)
elif self.save_dir_fmt == SaveDirFormat.FLAT:
return os.path.join(
self.output_dir,
"metrics",
(
self.config.tag()
if self.extra_tag == ""
else os.path.join(self.config.tag(), self.extra_tag)
),
start_time_str,
)
else:
raise NotImplementedError
def save_project_state(self):
path_parts = [
(
self.config.tag()
if self.extra_tag == ""
else os.path.join(self.config.tag(), self.extra_tag)
),
self.local_start_time_str,
]
if self.save_dir_fmt == SaveDirFormat.NESTED:
base_dir = os.path.join(
self.output_dir,
*path_parts,
"used_configs",
)
elif self.save_dir_fmt == SaveDirFormat.FLAT:
base_dir = os.path.join(
self.output_dir,
"used_configs",
*path_parts,
)
else:
raise NotImplementedError
os.makedirs(base_dir, exist_ok=True)
# Saving current git diff
try:
sha, diff_str = get_git_diff_of_project()
with open(os.path.join(base_dir, f"{sha}.patch"), "w") as f:
f.write(diff_str)
get_logger().info(f"Git diff saved to {base_dir}")
except subprocess.CalledProcessError:
get_logger().warning(
"Failed to get a git diff of the current project."
f" Is it possible that {os.getcwd()} is not under version control?"
)
# Saving configs
if self.loaded_config_src_files is not None:
for src_path in self.loaded_config_src_files:
if src_path == CONFIG_KWARGS_STR:
# We also save key-word arguments passed to the experiment
# initializer.
save_path = os.path.join(base_dir, "config_kwargs.json")
assert not os.path.exists(
save_path
), f"{save_path} should not already exist."
with open(save_path, "w") as f:
json.dump(json.loads(self.loaded_config_src_files[src_path]), f)
continue
assert os.path.isfile(src_path), f"Config file {src_path} not found"
src_path = os.path.abspath(src_path)
# To prevent overwriting files with the same name, we loop
# here until we find a prefix (if necessary) to prevent
# name collisions.
k = -1
while True:
prefix = "" if k == -1 else f"namecollision{k}__"
k += 1
dst_path = os.path.join(
base_dir,
f"{prefix}{os.path.basename(src_path)}",
)
if not os.path.exists(dst_path):
os.makedirs(os.path.dirname(dst_path), exist_ok=True)
with open(src_path, "r") as f:
file_contents = f.read()
with open(dst_path, "w") as f:
f.write(
f"### THIS FILE ORIGINALLY LOCATED AT '{src_path}'\n\n{file_contents}"
)
break
get_logger().info(f"Config files saved to {base_dir}")
for callback in self.callbacks:
callback.after_save_project_state(base_dir=base_dir)
def _update_keys(
self,
d: Union[Dict[str, Any], str],
tag_if_not_a_loss: str,
mode: str,
stage_component_uuid: Optional[str] = None,
) -> Union[Dict[str, Any], str]:
midfix = "-" if stage_component_uuid is None else f"-{stage_component_uuid}-"
def _convert(key: str):
if key.startswith("losses/"):
return f"{mode}{midfix}{key}"
else:
return f"{mode}{midfix}{tag_if_not_a_loss}/{key}"
if isinstance(d, str):
return _convert(d)
return {_convert(k): v for k, v in d.items()}
def _process_logging_packages(
self,
log_writer: Optional[SummaryWriter],
pkgs: Union[LoggingPackage, List[LoggingPackage]],
last_steps: Optional[int],
last_storage_uuid_to_total_experiences: Optional[Dict[str, int]],
last_time: Optional[float],
all_results: Optional[List[Any]] = None,
):
mode = pkgs[0].mode
assert all(
pkg.mode == mode for pkg in pkgs
), "All logging packages must be the same mode."
assert mode == self.mode or (
mode == VALID_MODE_STR and self.
gitextract_rp45h8jw/
├── .VERSION
├── .github/
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug_report.md
│ │ ├── feature_request.md
│ │ └── support_request.md
│ └── workflows/
│ ├── black.yml
│ ├── codeql.yml
│ ├── publish.yml
│ └── pytest.yml
├── .gitignore
├── .gitmodules
├── .pre-commit-config.yaml
├── CNAME
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── ROADMAP.md
├── allenact/
│ ├── __init__.py
│ ├── _constants.py
│ ├── algorithms/
│ │ ├── __init__.py
│ │ ├── offpolicy_sync/
│ │ │ ├── __init__.py
│ │ │ └── losses/
│ │ │ ├── __init__.py
│ │ │ └── abstract_offpolicy_loss.py
│ │ └── onpolicy_sync/
│ │ ├── __init__.py
│ │ ├── engine.py
│ │ ├── losses/
│ │ │ ├── __init__.py
│ │ │ ├── a2cacktr.py
│ │ │ ├── abstract_loss.py
│ │ │ ├── grouped_action_imitation.py
│ │ │ ├── imitation.py
│ │ │ └── ppo.py
│ │ ├── misc.py
│ │ ├── policy.py
│ │ ├── runner.py
│ │ ├── storage.py
│ │ └── vector_sampled_tasks.py
│ ├── base_abstractions/
│ │ ├── __init__.py
│ │ ├── callbacks.py
│ │ ├── distributions.py
│ │ ├── experiment_config.py
│ │ ├── misc.py
│ │ ├── preprocessor.py
│ │ ├── sensor.py
│ │ └── task.py
│ ├── embodiedai/
│ │ ├── __init__.py
│ │ ├── aux_losses/
│ │ │ ├── __init__.py
│ │ │ └── losses.py
│ │ ├── mapping/
│ │ │ ├── __init__.py
│ │ │ ├── mapping_losses.py
│ │ │ ├── mapping_models/
│ │ │ │ ├── __init__.py
│ │ │ │ └── active_neural_slam.py
│ │ │ └── mapping_utils/
│ │ │ ├── __init__.py
│ │ │ ├── map_builders.py
│ │ │ └── point_cloud_utils.py
│ │ ├── models/
│ │ │ ├── __init__.py
│ │ │ ├── aux_models.py
│ │ │ ├── basic_models.py
│ │ │ ├── fusion_models.py
│ │ │ ├── resnet.py
│ │ │ └── visual_nav_models.py
│ │ ├── preprocessors/
│ │ │ ├── __init__.py
│ │ │ └── resnet.py
│ │ ├── sensors/
│ │ │ ├── __init__.py
│ │ │ └── vision_sensors.py
│ │ └── storage/
│ │ ├── __init__.py
│ │ └── vdr_storage.py
│ ├── main.py
│ ├── setup.py
│ └── utils/
│ ├── __init__.py
│ ├── cache_utils.py
│ ├── cacheless_frcnn.py
│ ├── experiment_utils.py
│ ├── inference.py
│ ├── misc_utils.py
│ ├── model_utils.py
│ ├── multi_agent_viz_utils.py
│ ├── spaces_utils.py
│ ├── system.py
│ ├── tensor_utils.py
│ └── viz_utils.py
├── allenact_plugins/
│ ├── __init__.py
│ ├── babyai_plugin/
│ │ ├── __init__.py
│ │ ├── babyai_constants.py
│ │ ├── babyai_models.py
│ │ ├── babyai_tasks.py
│ │ ├── configs/
│ │ │ └── __init__.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── download_babyai_expert_demos.py
│ │ ├── get_instr_length_percentiles.py
│ │ └── truncate_expert_demos.py
│ ├── clip_plugin/
│ │ ├── __init__.py
│ │ ├── clip_preprocessors.py
│ │ ├── extra_environment.yml
│ │ └── extra_requirements.txt
│ ├── gym_plugin/
│ │ ├── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── gym_distributions.py
│ │ ├── gym_environment.py
│ │ ├── gym_models.py
│ │ ├── gym_sensors.py
│ │ └── gym_tasks.py
│ ├── habitat_plugin/
│ │ ├── __init__.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_environment_headless.yml
│ │ ├── extra_requirements.txt
│ │ ├── habitat_constants.py
│ │ ├── habitat_environment.py
│ │ ├── habitat_preprocessors.py
│ │ ├── habitat_sensors.py
│ │ ├── habitat_task_samplers.py
│ │ ├── habitat_tasks.py
│ │ ├── habitat_utils.py
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── agent_demo.py
│ │ └── make_map.py
│ ├── ithor_plugin/
│ │ ├── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── ithor_constants.py
│ │ ├── ithor_environment.py
│ │ ├── ithor_sensors.py
│ │ ├── ithor_task_samplers.py
│ │ ├── ithor_tasks.py
│ │ ├── ithor_util.py
│ │ ├── ithor_viz.py
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── make_objectnav_debug_dataset.py
│ │ └── make_pointnav_debug_dataset.py
│ ├── lighthouse_plugin/
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ └── __init__.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── lighthouse_environment.py
│ │ ├── lighthouse_models.py
│ │ ├── lighthouse_sensors.py
│ │ ├── lighthouse_tasks.py
│ │ ├── lighthouse_util.py
│ │ └── scripts/
│ │ └── __init__.py
│ ├── manipulathor_plugin/
│ │ ├── __init__.py
│ │ ├── arm_calculation_utils.py
│ │ ├── armpointnav_constants.py
│ │ ├── manipulathor_constants.py
│ │ ├── manipulathor_environment.py
│ │ ├── manipulathor_sensors.py
│ │ ├── manipulathor_task_samplers.py
│ │ ├── manipulathor_tasks.py
│ │ ├── manipulathor_utils.py
│ │ └── manipulathor_viz.py
│ ├── minigrid_plugin/
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ ├── __init__.py
│ │ │ └── minigrid_nomemory.py
│ │ ├── data/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── minigrid_environments.py
│ │ ├── minigrid_models.py
│ │ ├── minigrid_offpolicy.py
│ │ ├── minigrid_sensors.py
│ │ ├── minigrid_tasks.py
│ │ └── scripts/
│ │ └── __init__.py
│ ├── navigation_plugin/
│ │ ├── __init__.py
│ │ ├── objectnav/
│ │ │ ├── __init__.py
│ │ │ └── models.py
│ │ └── pointnav/
│ │ ├── __init__.py
│ │ └── models.py
│ ├── robothor_plugin/
│ │ ├── __init__.py
│ │ ├── configs/
│ │ │ └── __init__.py
│ │ ├── extra_environment.yml
│ │ ├── extra_requirements.txt
│ │ ├── robothor_constants.py
│ │ ├── robothor_distributions.py
│ │ ├── robothor_environment.py
│ │ ├── robothor_models.py
│ │ ├── robothor_preprocessors.py
│ │ ├── robothor_sensors.py
│ │ ├── robothor_task_samplers.py
│ │ ├── robothor_tasks.py
│ │ ├── robothor_viz.py
│ │ └── scripts/
│ │ ├── __init__.py
│ │ ├── make_objectnav_debug_dataset.py
│ │ └── make_pointnav_debug_dataset.py
│ └── setup.py
├── conda/
│ ├── environment-10.1.yml
│ ├── environment-10.2.yml
│ ├── environment-11.1.yml
│ ├── environment-9.2.yml
│ ├── environment-base.yml
│ ├── environment-cpu.yml
│ └── environment-dev.yml
├── constants.py
├── datasets/
│ ├── .gitignore
│ ├── .habitat_datasets_download_info.json
│ ├── .habitat_downloader_helper.py
│ ├── download_habitat_datasets.sh
│ └── download_navigation_datasets.sh
├── dev_requirements.txt
├── docs/
│ ├── .gitignore
│ ├── CNAME
│ ├── FAQ.md
│ ├── css/
│ │ └── extra.css
│ ├── getting_started/
│ │ ├── abstractions.md
│ │ ├── running-your-first-experiment.md
│ │ └── structure.md
│ ├── howtos/
│ │ ├── changing-rewards-and-losses.md
│ │ ├── defining-a-new-model.md
│ │ ├── defining-a-new-task.md
│ │ ├── defining-a-new-training-pipeline.md
│ │ ├── defining-an-experiment.md
│ │ ├── running-a-multi-agent-experiment.md
│ │ └── visualizing-results.md
│ ├── installation/
│ │ ├── download-datasets.md
│ │ ├── installation-allenact.md
│ │ └── installation-framework.md
│ ├── javascripts/
│ │ └── extra.js
│ ├── notebooks/
│ │ └── firstbook.md
│ ├── projects/
│ │ ├── advisor_2020/
│ │ │ └── README.md
│ │ ├── babyai_baselines/
│ │ │ └── README.md
│ │ ├── gym_baselines/
│ │ │ └── README.md
│ │ ├── objectnav_baselines/
│ │ │ └── README.md
│ │ ├── pointnav_baselines/
│ │ │ └── README.md
│ │ └── two_body_problem_2019/
│ │ └── README.md
│ └── tutorials/
│ ├── distributed-objectnav-tutorial.md
│ ├── gym-mujoco-tutorial.md
│ ├── gym-tutorial.md
│ ├── index.md
│ ├── minigrid-tutorial.md
│ ├── offpolicy-tutorial.md
│ ├── running-inference-on-a-pretrained-model.md
│ ├── training-a-pointnav-model.md
│ ├── training-pipelines.md
│ └── transfering-to-a-different-environment-framework.md
├── main.py
├── mkdocs.yml
├── mypy.ini
├── overrides/
│ └── main.html
├── pretrained_model_ckpts/
│ ├── .gitignore
│ └── download_navigation_model_ckpts.sh
├── projects/
│ ├── __init__.py
│ ├── babyai_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ └── experiments/
│ │ ├── __init__.py
│ │ ├── base.py
│ │ ├── go_to_local/
│ │ │ ├── __init__.py
│ │ │ ├── a2c.py
│ │ │ ├── base.py
│ │ │ ├── bc.py
│ │ │ ├── bc_teacher_forcing.py
│ │ │ ├── dagger.py
│ │ │ ├── distributed_bc_offpolicy.py
│ │ │ ├── distributed_bc_teacher_forcing.py
│ │ │ └── ppo.py
│ │ └── go_to_obj/
│ │ ├── __init__.py
│ │ ├── a2c.py
│ │ ├── base.py
│ │ ├── bc.py
│ │ ├── bc_teacher_forcing.py
│ │ ├── dagger.py
│ │ └── ppo.py
│ ├── gym_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── gym_base.py
│ │ │ ├── gym_humanoid_base.py
│ │ │ ├── gym_humanoid_ddppo.py
│ │ │ ├── gym_mujoco_base.py
│ │ │ ├── gym_mujoco_ddppo.py
│ │ │ └── mujoco/
│ │ │ ├── __init__.py
│ │ │ ├── gym_mujoco_ant_ddppo.py
│ │ │ ├── gym_mujoco_halfcheetah_ddppo.py
│ │ │ ├── gym_mujoco_hopper_ddppo.py
│ │ │ ├── gym_mujoco_humanoid_ddppo.py
│ │ │ ├── gym_mujoco_inverteddoublependulum_ddppo.py
│ │ │ ├── gym_mujoco_invertedpendulum_ddppo.py
│ │ │ ├── gym_mujoco_reacher_ddppo.py
│ │ │ ├── gym_mujoco_swimmer_ddppo.py
│ │ │ └── gym_mujoco_walker2d_ddppo.py
│ │ └── models/
│ │ ├── __init__.py
│ │ └── gym_models.py
│ ├── manipulathor_baselines/
│ │ ├── __init__.py
│ │ └── armpointnav_baselines/
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── armpointnav_base.py
│ │ │ ├── armpointnav_mixin_ddppo.py
│ │ │ ├── armpointnav_mixin_simplegru.py
│ │ │ ├── armpointnav_thor_base.py
│ │ │ └── ithor/
│ │ │ ├── __init__.py
│ │ │ ├── armpointnav_depth.py
│ │ │ ├── armpointnav_disjoint_depth.py
│ │ │ ├── armpointnav_ithor_base.py
│ │ │ ├── armpointnav_no_vision.py
│ │ │ ├── armpointnav_rgb.py
│ │ │ └── armpointnav_rgbdepth.py
│ │ └── models/
│ │ ├── __init__.py
│ │ ├── arm_pointnav_models.py
│ │ ├── base_models.py
│ │ ├── disjoint_arm_pointnav_models.py
│ │ └── manipulathor_net_utils.py
│ ├── objectnav_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── clip/
│ │ │ │ ├── __init__.py
│ │ │ │ └── mixins.py
│ │ │ ├── habitat/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── clip/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ ├── objectnav_habitat_rgb_clipresnet50gru_ddppo.py
│ │ │ │ │ └── objectnav_habitat_rgb_clipresnet50gru_ddppo_increasingrollouts.py
│ │ │ │ └── objectnav_habitat_base.py
│ │ │ ├── ithor/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── objectnav_ithor_base.py
│ │ │ │ ├── objectnav_ithor_depth_resnet18gru_ddppo.py
│ │ │ │ ├── objectnav_ithor_rgb_resnet18gru_ddppo.py
│ │ │ │ └── objectnav_ithor_rgbd_resnet18gru_ddppo.py
│ │ │ ├── objectnav_base.py
│ │ │ ├── objectnav_thor_base.py
│ │ │ └── robothor/
│ │ │ ├── __init__.py
│ │ │ ├── beta/
│ │ │ │ ├── README.md
│ │ │ │ ├── __init__.py
│ │ │ │ ├── objectnav_robothor_rgb_resnetgru_ddppo_and_gbc.py
│ │ │ │ └── objectnav_robothor_rgb_unfrozenresnet18gru_vdr_ddppo.py
│ │ │ ├── clip/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── objectnav_robothor_rgb_clipresnet50gru_ddppo.py
│ │ │ │ └── objectnav_robothor_rgb_clipresnet50x16gru_ddppo.py
│ │ │ ├── objectnav_robothor_base.py
│ │ │ ├── objectnav_robothor_depth_resnet18gru_ddppo.py
│ │ │ ├── objectnav_robothor_rgb_resnet18gru_dagger.py
│ │ │ ├── objectnav_robothor_rgb_resnet18gru_ddppo.py
│ │ │ ├── objectnav_robothor_rgb_resnet50gru_ddppo.py
│ │ │ ├── objectnav_robothor_rgb_unfrozenresnet18gru_ddppo.py
│ │ │ └── objectnav_robothor_rgbd_resnet18gru_ddppo.py
│ │ └── mixins.py
│ ├── pointnav_baselines/
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── experiments/
│ │ │ ├── __init__.py
│ │ │ ├── habitat/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── clip/
│ │ │ │ │ ├── __init__.py
│ │ │ │ │ └── pointnav_habitat_rgb_clipresnet50gru_ddppo.py
│ │ │ │ ├── pointnav_habitat_base.py
│ │ │ │ ├── pointnav_habitat_depth_simpleconvgru_ddppo.py
│ │ │ │ ├── pointnav_habitat_rgb_simpleconvgru_ddppo.py
│ │ │ │ └── pointnav_habitat_rgbd_simpleconvgru_ddppo.py
│ │ │ ├── ithor/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── pointnav_ithor_base.py
│ │ │ │ ├── pointnav_ithor_depth_simpleconvgru_ddppo.py
│ │ │ │ ├── pointnav_ithor_rgb_simpleconvgru_ddppo.py
│ │ │ │ └── pointnav_ithor_rgbd_simpleconvgru_ddppo.py
│ │ │ ├── pointnav_base.py
│ │ │ ├── pointnav_thor_base.py
│ │ │ └── robothor/
│ │ │ ├── __init__.py
│ │ │ ├── pointnav_robothor_base.py
│ │ │ ├── pointnav_robothor_depth_simpleconvgru_ddppo.py
│ │ │ ├── pointnav_robothor_rgb_simpleconvgru_ddppo.py
│ │ │ └── pointnav_robothor_rgbd_simpleconvgru_ddppo.py
│ │ └── mixins.py
│ └── tutorials/
│ ├── __init__.py
│ ├── distributed_objectnav_tutorial.py
│ ├── gym_mujoco_tutorial.py
│ ├── gym_tutorial.py
│ ├── minigrid_offpolicy_tutorial.py
│ ├── minigrid_tutorial.py
│ ├── minigrid_tutorial_conds.py
│ ├── navtopartner_robothor_rgb_ppo.py
│ ├── object_nav_ithor_dagger_then_ppo_one_object.py
│ ├── object_nav_ithor_dagger_then_ppo_one_object_viz.py
│ ├── object_nav_ithor_ppo_one_object.py
│ ├── pointnav_habitat_rgb_ddppo.py
│ ├── pointnav_ithor_rgb_ddppo.py
│ ├── running_inference_tutorial.py
│ └── training_a_pointnav_model.py
├── requirements.txt
├── scripts/
│ ├── auto_format.sh
│ ├── build_docs.py
│ ├── build_docs.sh
│ ├── dcommand.py
│ ├── dconfig.py
│ ├── dkill.py
│ ├── dmain.py
│ ├── literate.py
│ ├── release.py
│ ├── run_tests.sh
│ └── startx.py
└── tests/
├── .gitignore
├── __init__.py
├── hierarchical_policies/
│ ├── __init__.py
│ └── test_minigrid_conditional.py
├── manipulathor_plugin/
│ ├── __init__.py
│ └── test_utils.py
├── mapping/
│ ├── __init__.py
│ └── test_ai2thor_mapping.py
├── multiprocessing/
│ ├── __init__.py
│ └── test_frozen_attribs.py
├── sync_algs_cpu/
│ ├── __init__.py
│ └── test_to_to_obj_trains.py
├── utils/
│ ├── __init__.py
│ ├── test_inference_agent.py
│ └── test_spaces.py
└── vision/
├── __init__.py
└── test_pillow_rescaling.py
Showing preview only (200K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2386 symbols across 212 files)
FILE: allenact/algorithms/offpolicy_sync/losses/abstract_offpolicy_loss.py
class AbstractOffPolicyLoss (line 14) | class AbstractOffPolicyLoss(Generic[ModelType], Loss):
method loss (line 20) | def loss( # type: ignore
FILE: allenact/algorithms/onpolicy_sync/engine.py
class OnPolicyRLEngine (line 93) | class OnPolicyRLEngine(object):
method __init__ (line 103) | def __init__(
method vector_tasks (line 302) | def vector_tasks(
method worker_seeds (line 344) | def worker_seeds(nprocesses: int, initial_seed: Optional[int]) -> List...
method get_sampler_fn_args (line 356) | def get_sampler_fn_args(self, seeds: Optional[List[int]] = None):
method checkpoint_load (line 397) | def checkpoint_load(
method aggregate_task_metrics (line 422) | def aggregate_task_metrics(
method _preprocess_observations (line 457) | def _preprocess_observations(self, batched_observations):
method remove_paused (line 462) | def remove_paused(self, observations):
method initialize_storage_and_viz (line 479) | def initialize_storage_and_viz(
method num_active_samplers (line 527) | def num_active_samplers(self):
method act (line 532) | def act(
method aggregate_and_send_logging_package (line 549) | def aggregate_and_send_logging_package(
method _active_memory (line 598) | def _active_memory(memory, keep):
method probe (line 601) | def probe(self, dones: List[bool], npaused, period=100000):
method collect_step_across_all_task_samplers (line 656) | def collect_step_across_all_task_samplers(
method distributed_weighted_sum (line 776) | def distributed_weighted_sum(
method distributed_reduce (line 793) | def distributed_reduce(
method backprop_step (line 804) | def backprop_step(
method save_error_data (line 812) | def save_error_data(self, batch: Dict[str, Any]):
method step_count (line 816) | def step_count(self) -> int:
method compute_losses_track_them_and_backprop (line 823) | def compute_losses_track_them_and_backprop(
method close (line 1108) | def close(self, verbose=True):
method is_closed (line 1140) | def is_closed(self):
method is_closing (line 1144) | def is_closing(self):
method __del__ (line 1147) | def __del__(self):
method __enter__ (line 1150) | def __enter__(self):
method __exit__ (line 1153) | def __exit__(self, exc_type, exc_val, exc_tb):
class OnPolicyTrainer (line 1157) | class OnPolicyTrainer(OnPolicyRLEngine):
method __init__ (line 1158) | def __init__(
method advance_seed (line 1272) | def advance_seed(
method deterministic_seeds (line 1290) | def deterministic_seeds(self) -> None:
method save_error_data (line 1299) | def save_error_data(self, batch: Dict[str, Any]) -> str:
method aggregate_and_send_logging_package (line 1329) | def aggregate_and_send_logging_package(
method checkpoint_save (line 1353) | def checkpoint_save(self, pipeline_stage_index: Optional[int] = None) ...
method checkpoint_load (line 1383) | def checkpoint_load(
method step_count (line 1405) | def step_count(self):
method step_count (line 1409) | def step_count(self, val: int) -> None:
method log_interval (line 1413) | def log_interval(self):
method approx_steps (line 1419) | def approx_steps(self):
method act (line 1428) | def act(
method advantage_stats (line 1465) | def advantage_stats(self, advantages: torch.Tensor) -> Dict[str, torch...
method backprop_step (line 1495) | def backprop_step(
method _save_checkpoint_then_send_checkpoint_for_validation_and_update_last_save_counter (line 1538) | def _save_checkpoint_then_send_checkpoint_for_validation_and_update_la...
method run_pipeline (line 1553) | def run_pipeline(self, valid_on_initial_weights: bool = False):
method train (line 1897) | def train(
class OnPolicyInference (line 1937) | class OnPolicyInference(OnPolicyRLEngine):
method __init__ (line 1938) | def __init__(
method run_eval (line 1976) | def run_eval(
method skip_to_latest (line 2321) | def skip_to_latest(checkpoints_queue: mp.Queue, command: Optional[str]...
method process_checkpoints (line 2354) | def process_checkpoints(self):
FILE: allenact/algorithms/onpolicy_sync/losses/a2cacktr.py
class A2CACKTR (line 16) | class A2CACKTR(AbstractActorCriticLoss):
method __init__ (line 28) | def __init__(
method loss_per_step (line 49) | def loss_per_step( # type: ignore
method loss (line 94) | def loss( # type: ignore
class A2C (line 129) | class A2C(A2CACKTR):
method __init__ (line 132) | def __init__(
class ACKTR (line 150) | class ACKTR(A2CACKTR):
method __init__ (line 157) | def __init__(
FILE: allenact/algorithms/onpolicy_sync/losses/abstract_loss.py
class AbstractActorCriticLoss (line 13) | class AbstractActorCriticLoss(Loss):
method loss (line 19) | def loss( # type: ignore
FILE: allenact/algorithms/onpolicy_sync/losses/grouped_action_imitation.py
class GroupedActionImitation (line 14) | class GroupedActionImitation(AbstractActorCriticLoss):
method __init__ (line 15) | def __init__(
method loss (line 34) | def loss( # type: ignore
FILE: allenact/algorithms/onpolicy_sync/losses/imitation.py
class Imitation (line 23) | class Imitation(AbstractActorCriticLoss):
method __init__ (line 26) | def __init__(
method group_loss (line 34) | def group_loss(
method loss (line 66) | def loss( # type: ignore
FILE: allenact/algorithms/onpolicy_sync/losses/ppo.py
class PPO (line 15) | class PPO(AbstractActorCriticLoss):
method __init__ (line 32) | def __init__(
method loss_per_step (line 62) | def loss_per_step(
method loss (line 131) | def loss( # type: ignore
class PPOValue (line 166) | class PPOValue(AbstractActorCriticLoss):
method __init__ (line 175) | def __init__(
method loss (line 192) | def loss( # type: ignore
FILE: allenact/algorithms/onpolicy_sync/misc.py
class TrackingInfoType (line 7) | class TrackingInfoType(Enum):
class TrackingInfo (line 14) | class TrackingInfo:
FILE: allenact/algorithms/onpolicy_sync/policy.py
class ActorCriticModel (line 29) | class ActorCriticModel(Generic[DistributionType], nn.Module):
method __init__ (line 40) | def __init__(self, action_space: gym.Space, observation_space: SpaceDi...
method recurrent_memory_specification (line 54) | def recurrent_memory_specification(self) -> Optional[FullMemorySpecType]:
method _recurrent_memory_specification (line 83) | def _recurrent_memory_specification(self) -> Optional[FullMemorySpecTy...
method forward (line 108) | def forward( # type:ignore
class LinearActorCriticHead (line 139) | class LinearActorCriticHead(nn.Module):
method __init__ (line 140) | def __init__(self, input_size: int, num_actions: int):
method forward (line 149) | def forward(self, x) -> Tuple[CategoricalDistr, torch.Tensor]:
class LinearCriticHead (line 163) | class LinearCriticHead(nn.Module):
method __init__ (line 164) | def __init__(self, input_size: int):
method forward (line 170) | def forward(self, x):
class LinearActorHead (line 174) | class LinearActorHead(nn.Module):
method __init__ (line 175) | def __init__(self, num_inputs: int, num_outputs: int):
method forward (line 182) | def forward(self, x: torch.FloatTensor): # type: ignore
FILE: allenact/algorithms/onpolicy_sync/runner.py
class SaveDirFormat (line 63) | class SaveDirFormat(enum.Enum):
class OnPolicyRunner (line 80) | class OnPolicyRunner(object):
method __init__ (line 81) | def __init__(
method callbacks (line 153) | def callbacks(self):
method local_start_time_str (line 157) | def local_start_time_str(self) -> str:
method running_validation (line 166) | def running_validation(self):
method init_context (line 182) | def init_context(
method setup_callback_classes (line 202) | def setup_callback_classes(self, callbacks: Optional[str]) -> Set[Call...
method _acquire_unique_local_start_time_string (line 261) | def _acquire_unique_local_start_time_string(self) -> str:
method worker_devices (line 309) | def worker_devices(self, mode: str):
method local_worker_ids (line 322) | def local_worker_ids(self, mode: str):
method init_visualizer (line 334) | def init_visualizer(self, mode: str):
method init_process (line 343) | def init_process(mode: str, id: int, to_close_on_termination: OnPolicy...
method init_worker (line 380) | def init_worker(engine_class, args, kwargs):
method _get_callback_sensors (line 395) | def _get_callback_sensors(self) -> List[Sensor]:
method train_loop (line 404) | def train_loop(
method valid_loop (line 432) | def valid_loop(id: int = 0, *engine_args, **engine_kwargs):
method test_loop (line 445) | def test_loop(id: int = 0, *engine_args, **engine_kwargs):
method _initialize_start_train_or_start_test (line 455) | def _initialize_start_train_or_start_test(self):
method get_port (line 477) | def get_port(self):
method start_train (line 495) | def start_train(
method start_test (line 671) | def start_test(
method checkpoint_start_time_str (line 772) | def checkpoint_start_time_str(checkpoint_file_name):
method checkpoint_log_folder_str (line 780) | def checkpoint_log_folder_str(checkpoint_file_name):
method experiment_name (line 788) | def experiment_name(self):
method checkpoint_dir (line 793) | def checkpoint_dir(
method log_writer_path (line 822) | def log_writer_path(self, start_time_str: str) -> str:
method metric_path (line 859) | def metric_path(self, start_time_str: str) -> str:
method save_project_state (line 881) | def save_project_state(self):
method _update_keys (line 961) | def _update_keys(
method _process_logging_packages (line 980) | def _process_logging_packages(
method process_valid_package (line 1261) | def process_valid_package(
method process_train_packages (line 1276) | def process_train_packages(
method process_test_packages (line 1292) | def process_test_packages(
method log_and_close (line 1307) | def log_and_close(
method get_checkpoint_files (line 1509) | def get_checkpoint_files(
method step_from_checkpoint (line 1557) | def step_from_checkpoint(ckpt_path: str) -> int:
method close (line 1574) | def close(self, verbose=True):
method __del__ (line 1608) | def __del__(self):
method __enter__ (line 1611) | def __enter__(self):
method __exit__ (line 1614) | def __exit__(self, exc_type, exc_val, exc_tb):
FILE: allenact/algorithms/onpolicy_sync/storage.py
class ExperienceStorage (line 34) | class ExperienceStorage(abc.ABC):
method initialize (line 36) | def initialize(self, *, observations: ObservationType, **kwargs):
method add (line 40) | def add(
method before_updates (line 65) | def before_updates(self, **kwargs):
method after_updates (line 68) | def after_updates(self, **kwargs) -> int:
method to (line 72) | def to(self, device: torch.device):
method set_partition (line 76) | def set_partition(self, index: int, num_parts: int):
method total_experiences (line 81) | def total_experiences(self) -> int:
class RolloutStorage (line 85) | class RolloutStorage(ExperienceStorage, abc.ABC):
method initialize (line 88) | def initialize(
method agent_input_for_next_step (line 100) | def agent_input_for_next_step(self) -> Dict[str, Any]:
method sampler_select (line 104) | def sampler_select(self, keep_list: Sequence[int]):
class StreamingStorageMixin (line 108) | class StreamingStorageMixin(abc.ABC):
method next_batch (line 110) | def next_batch(self) -> Dict[str, Any]:
method reset_stream (line 113) | def reset_stream(self):
method empty (line 117) | def empty(self) -> bool:
class MiniBatchStorageMixin (line 121) | class MiniBatchStorageMixin(abc.ABC):
method batched_experience_generator (line 123) | def batched_experience_generator(
class RolloutBlockStorage (line 130) | class RolloutBlockStorage(RolloutStorage, MiniBatchStorageMixin):
method __init__ (line 135) | def __init__(self, init_size: int = 50):
method initialize (line 173) | def initialize(
method total_experiences (line 211) | def total_experiences(self) -> int:
method total_experiences (line 215) | def total_experiences(self, value: int):
method set_partition (line 218) | def set_partition(self, index: int, num_parts: int):
method value_preds (line 222) | def value_preds(self) -> torch.Tensor:
method rewards (line 226) | def rewards(self) -> torch.Tensor:
method returns (line 230) | def returns(self) -> torch.Tensor:
method action_log_probs (line 234) | def action_log_probs(self) -> torch.Tensor:
method actions (line 238) | def actions(self) -> torch.Tensor:
method prev_actions (line 242) | def prev_actions(self) -> torch.Tensor:
method masks (line 246) | def masks(self) -> torch.Tensor:
method observations (line 250) | def observations(self) -> Memory:
method create_memory (line 254) | def create_memory(
method to (line 279) | def to(self, device: torch.device):
method insert_observations (line 297) | def insert_observations(
method insert_memory (line 309) | def insert_memory(
method insert_tensors (line 329) | def insert_tensors(
method create_tensor_storage (line 400) | def create_tensor_storage(
method _double_storage_size (line 405) | def _double_storage_size(self):
method add (line 438) | def add(
method sampler_select (line 502) | def sampler_select(self, keep_list: Sequence[int]):
method before_updates (line 519) | def before_updates(
method after_updates (line 546) | def after_updates(self, **kwargs):
method _extend_tensor_with_ones (line 565) | def _extend_tensor_with_ones(stored_tensor: torch.Tensor, desired_num_...
method compute_returns (line 572) | def compute_returns(
method batched_experience_generator (line 601) | def batched_experience_generator(
method unflatten_observations (line 677) | def unflatten_observations(self, flattened_batch: Memory) -> Observati...
method pick_observation_step (line 689) | def pick_observation_step(self, step: int) -> ObservationType:
method pick_memory_step (line 692) | def pick_memory_step(self, step: int) -> Memory:
method pick_prev_actions_step (line 696) | def pick_prev_actions_step(self, step: int) -> ActionType:
method agent_input_for_next_step (line 699) | def agent_input_for_next_step(self) -> Dict[str, Any]:
FILE: allenact/algorithms/onpolicy_sync/vector_sampled_tasks.py
class DelaySignalHandling (line 68) | class DelaySignalHandling:
method __init__ (line 70) | def __init__(self):
method __enter__ (line 76) | def __enter__(self):
method int_handler (line 82) | def int_handler(self, sig, frame):
method term_handler (line 86) | def term_handler(self, sig, frame):
method __exit__ (line 90) | def __exit__(self, type, value, traceback):
class VectorSampledTasks (line 116) | class VectorSampledTasks:
method __init__ (line 151) | def __init__(
method _create_read_function_with_timeout (line 262) | def _create_read_function_with_timeout(
method _reset_sampler_index_to_process_ind_and_subprocess_ind (line 280) | def _reset_sampler_index_to_process_ind_and_subprocess_ind(self):
method _partition_to_processes (line 289) | def _partition_to_processes(self, seq: Union[Iterator, Sequence]):
method is_closed (line 304) | def is_closed(self) -> bool:
method num_unpaused_tasks (line 309) | def num_unpaused_tasks(self) -> int:
method mp_ctx (line 319) | def mp_ctx(self):
method _task_sampling_loop_worker (line 329) | def _task_sampling_loop_worker(
method _spawn_workers (line 429) | def _spawn_workers(
method next_task (line 483) | def next_task(self, **kwargs):
method get_observations (line 498) | def get_observations(self):
method command_at (line 509) | def command_at(
method call_at (line 531) | def call_at(
method next_task_at (line 556) | def next_task_at(self, sampler_index: int) -> List[RLStepResult]:
method step_at (line 574) | def step_at(self, sampler_index: int, action: Any) -> List[RLStepResult]:
method async_step (line 592) | def async_step(self, actions: Sequence[Any]) -> None:
method wait_step (line 605) | def wait_step(self) -> List[Dict[str, Any]]:
method step (line 613) | def step(self, actions: Sequence[Any]):
method reset_all (line 627) | def reset_all(self):
method set_seeds (line 632) | def set_seeds(self, seeds: List[int]):
method close (line 641) | def close(self) -> None:
method pause_at (line 671) | def pause_at(self, sampler_index: int) -> None:
method resume_all (line 708) | def resume_all(self) -> None:
method command (line 724) | def command(
method call (line 748) | def call(
method attr_at (line 786) | def attr_at(self, sampler_index: int, attr_name: str) -> Any:
method attr (line 801) | def attr(self, attr_names: Union[List[str], str]) -> List[Any]:
method render (line 817) | def render(
method _valid_start_methods (line 844) | def _valid_start_methods(self) -> Set[str]:
method __del__ (line 847) | def __del__(self):
method __enter__ (line 850) | def __enter__(self):
method __exit__ (line 853) | def __exit__(self, exc_type, exc_val, exc_tb):
class SingleProcessVectorSampledTasks (line 857) | class SingleProcessVectorSampledTasks(object):
method __init__ (line 881) | def __init__(
method is_closed (line 936) | def is_closed(self) -> bool:
method mp_ctx (line 941) | def mp_ctx(self) -> Optional[BaseContext]:
method num_unpaused_tasks (line 945) | def num_unpaused_tasks(self) -> int:
method _task_sampling_loop_generator_fn (line 955) | def _task_sampling_loop_generator_fn(
method _create_generators (line 1096) | def _create_generators(
method next_task (line 1125) | def next_task(self, **kwargs):
method get_observations (line 1140) | def get_observations(self):
method next_task_at (line 1151) | def next_task_at(self, index_process: int) -> List[RLStepResult]:
method step_at (line 1167) | def step_at(self, index_process: int, action: int) -> List[RLStepResult]:
method step (line 1181) | def step(self, actions: List[List[int]]):
method reset_all (line 1197) | def reset_all(self):
method set_seeds (line 1202) | def set_seeds(self, seeds: List[int]):
method close (line 1214) | def close(self) -> None:
method pause_at (line 1229) | def pause_at(self, sampler_index: int) -> None:
method resume_all (line 1243) | def resume_all(self) -> None:
method command_at (line 1249) | def command_at(
method command (line 1267) | def command(
method call_at (line 1284) | def call_at(
method call (line 1307) | def call(
method attr_at (line 1340) | def attr_at(self, sampler_index: int, attr_name: str) -> Any:
method attr (line 1357) | def attr(self, attr_names: Union[List[str], str]) -> List[Any]:
method render (line 1376) | def render(
method __del__ (line 1405) | def __del__(self):
method __enter__ (line 1408) | def __enter__(self):
method __exit__ (line 1411) | def __exit__(self, exc_type, exc_val, exc_tb):
FILE: allenact/base_abstractions/callbacks.py
class Callback (line 13) | class Callback(abc.ABC):
method setup (line 14) | def setup(
method on_train_log (line 23) | def on_train_log(
method on_valid_log (line 36) | def on_valid_log(
method on_test_log (line 49) | def on_test_log(
method after_save_project_state (line 62) | def after_save_project_state(self, base_dir: str) -> None:
method callback_sensors (line 65) | def callback_sensors(self) -> Optional[Sequence[Sensor]]:
FILE: allenact/base_abstractions/distributions.py
class Distr (line 22) | class Distr(abc.ABC):
method log_prob (line 24) | def log_prob(self, actions: Any):
method entropy (line 29) | def entropy(self):
method sample (line 34) | def sample(self, sample_shape=torch.Size()):
method mode (line 38) | def mode(self):
class CategoricalDistr (line 46) | class CategoricalDistr(torch.distributions.Categorical, Distr):
method mode (line 53) | def mode(self):
method log_prob (line 56) | def log_prob(self, value: torch.Tensor):
method log_probs_tensor (line 75) | def log_probs_tensor(self):
method probs_tensor (line 79) | def probs_tensor(self):
class ConditionalDistr (line 83) | class ConditionalDistr(Distr):
method __init__ (line 93) | def __init__(
method log_prob (line 124) | def log_prob(self, actions):
method entropy (line 127) | def entropy(self):
method condition_on_input (line 130) | def condition_on_input(self, **ready_actions):
method reset (line 142) | def reset(self):
method sample (line 148) | def sample(self, sample_shape=torch.Size()) -> OrderedDict:
method mode (line 151) | def mode(self) -> OrderedDict:
class SequentialDistr (line 155) | class SequentialDistr(Distr):
method __init__ (line 156) | def __init__(self, *conditional_distrs: ConditionalDistr):
method sample (line 163) | def sample(self, sample_shape=torch.Size()):
method mode (line 170) | def mode(self):
method conditional_entropy (line 177) | def conditional_entropy(self):
method entropy (line 183) | def entropy(self):
method log_prob (line 189) | def log_prob(
class TrackingCallback (line 212) | class TrackingCallback(Protocol):
method __call__ (line 213) | def __call__(self, type: TrackingInfoType, info: Dict[str, Any], n: in...
class TeacherForcingDistr (line 216) | class TeacherForcingDistr(Distr):
method __init__ (line 217) | def __init__(
method enforce (line 248) | def enforce(
method log_prob (line 302) | def log_prob(self, actions: Any):
method entropy (line 305) | def entropy(self):
method conditional_entropy (line 308) | def conditional_entropy(self):
method sample (line 316) | def sample(self, sample_shape=torch.Size()):
class AddBias (line 353) | class AddBias(nn.Module):
method __init__ (line 356) | def __init__(self, bias: torch.FloatTensor):
method forward (line 366) | def forward(self, x: torch.FloatTensor) -> torch.FloatTensor: # type:...
FILE: allenact/base_abstractions/experiment_config.py
function split_processes_onto_devices (line 17) | def split_processes_onto_devices(nprocesses: int, ndevices: int):
class MachineParams (line 27) | class MachineParams(object):
method __init__ (line 28) | def __init__(
method set_local_worker_ids (line 77) | def set_local_worker_ids(self, local_worker_ids: Optional[List[int]]):
method instance_from (line 86) | def instance_from(
method _standardize_devices (line 95) | def _standardize_devices(
method sensor_preprocessor_graph (line 127) | def sensor_preprocessor_graph(self) -> Optional[SensorPreprocessorGraph]:
method set_visualizer (line 143) | def set_visualizer(self, viz: VizSuite):
method visualizer (line 150) | def visualizer(self) -> Optional[VizSuite]:
class FrozenClassVariables (line 163) | class FrozenClassVariables(abc.ABCMeta):
method __setattr__ (line 171) | def __setattr__(cls, attr, value):
class ExperimentConfig (line 188) | class ExperimentConfig(metaclass=FrozenClassVariables):
method tag (line 199) | def tag(self) -> str:
method training_pipeline (line 204) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method machine_params (line 218) | def machine_params(
method create_model (line 240) | def create_model(self, **kwargs) -> nn.Module:
method make_sampler_fn (line 245) | def make_sampler_fn(self, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 256) | def train_task_sampler_args(
method valid_task_sampler_args (line 284) | def valid_task_sampler_args(
method test_task_sampler_args (line 300) | def test_task_sampler_args(
FILE: allenact/base_abstractions/misc.py
class RLStepResult (line 23) | class RLStepResult(NamedTuple):
method clone (line 29) | def clone(self, new_info: Dict[str, Any]):
method merge (line 41) | def merge(self, other: "RLStepResult"):
class ActorCriticOutput (line 55) | class ActorCriticOutput(tuple, Generic[DistributionType]):
method __new__ (line 61) | def __new__(
method __repr__ (line 73) | def __repr__(self) -> str:
class Memory (line 81) | class Memory(Dict):
method __init__ (line 82) | def __init__(self, *args, **kwargs):
method check_append (line 111) | def check_append(
method tensor (line 146) | def tensor(self, key: str) -> torch.Tensor:
method sampler_dim (line 160) | def sampler_dim(self, key: str) -> int:
method sampler_select (line 174) | def sampler_select(self, keep: Sequence[int]) -> "Memory":
method set_tensor (line 209) | def set_tensor(self, key: str, tensor: torch.Tensor) -> "Memory":
method step_select (line 231) | def step_select(self, step: int) -> "Memory":
method step_squeeze (line 261) | def step_squeeze(self, step: int) -> "Memory":
method slice (line 286) | def slice(
method to (line 346) | def to(self, device: torch.device) -> "Memory":
class Loss (line 354) | class Loss(abc.ABC):
class LossOutput (line 359) | class LossOutput:
class GenericAbstractLoss (line 368) | class GenericAbstractLoss(Loss):
method loss (line 371) | def loss( # type: ignore
FILE: allenact/base_abstractions/preprocessor.py
class Preprocessor (line 14) | class Preprocessor(abc.ABC):
method __init__ (line 30) | def __init__(
method process (line 42) | def process(self, obs: Dict[str, Any], *args: Any, **kwargs: Any) -> Any:
method to (line 56) | def to(self, device: torch.device) -> "Preprocessor":
class SensorPreprocessorGraph (line 60) | class SensorPreprocessorGraph:
method __init__ (line 87) | def __init__(
method get (line 147) | def get(self, uuid: str) -> Preprocessor:
method to (line 160) | def to(self, device: torch.device) -> "SensorPreprocessorGraph":
method get_observations (line 166) | def get_observations(
class PreprocessorGraph (line 183) | class PreprocessorGraph(SensorPreprocessorGraph):
method __init__ (line 184) | def __init__(self, *args, **kwargs):
class ObservationSet (line 191) | class ObservationSet:
method __init__ (line 192) | def __init__(self, *args, **kwargs) -> None:
FILE: allenact/base_abstractions/sensor.py
class Sensor (line 38) | class Sensor(Generic[EnvType, SubTaskType]):
method __init__ (line 53) | def __init__(self, uuid: str, observation_space: gym.Space, **kwargs: ...
method get_observation (line 57) | def get_observation(
class SensorSuite (line 74) | class SensorSuite(Generic[EnvType]):
method __init__ (line 87) | def __init__(self, sensors: Sequence[Sensor]) -> None:
method get (line 104) | def get(self, uuid: str) -> Sensor:
method get_observations (line 117) | def get_observations(
class AbstractExpertSensor (line 137) | class AbstractExpertSensor(Sensor[EnvType, SubTaskType], abc.ABC):
method __init__ (line 145) | def __init__(
method flagged_group_space (line 210) | def flagged_group_space(cls, group_space: gym.spaces.Space) -> gym.spa...
method flagged_space (line 222) | def flagged_space(
method _get_observation_space (line 248) | def _get_observation_space(self) -> gym.spaces.Dict:
method _zeroed_observation (line 261) | def _zeroed_observation(self) -> Union[OrderedDict, Tuple]:
method flatten_output (line 271) | def flatten_output(self, unflattened):
method query_expert (line 282) | def query_expert(
method get_observation (line 299) | def get_observation(
class AbstractExpertActionSensor (line 327) | class AbstractExpertActionSensor(AbstractExpertSensor, abc.ABC):
method __init__ (line 328) | def __init__(
method flagged_group_space (line 340) | def flagged_group_space(cls, group_space: gym.spaces.Space) -> gym.spa...
class ExpertActionSensor (line 356) | class ExpertActionSensor(AbstractExpertActionSensor):
method query_expert (line 360) | def query_expert(
class AbstractExpertPolicySensor (line 368) | class AbstractExpertPolicySensor(AbstractExpertSensor, abc.ABC):
method __init__ (line 369) | def __init__(
method flagged_group_space (line 381) | def flagged_group_space(cls, group_space: gym.spaces.Space) -> gym.spa...
class ExpertPolicySensor (line 398) | class ExpertPolicySensor(AbstractExpertPolicySensor):
method query_expert (line 402) | def query_expert(
FILE: allenact/base_abstractions/task.py
class Task (line 23) | class Task(Generic[EnvType]):
method __init__ (line 48) | def __init__(
method get_observations (line 66) | def get_observations(self, **kwargs) -> Any:
method action_space (line 71) | def action_space(self) -> gym.Space:
method render (line 81) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method _increment_num_steps_taken (line 100) | def _increment_num_steps_taken(self) -> None:
method step (line 105) | def step(self, action: Any) -> RLStepResult:
method _step (line 143) | def _step(self, action: Any) -> RLStepResult:
method reached_max_steps (line 167) | def reached_max_steps(self) -> bool:
method reached_terminal_state (line 172) | def reached_terminal_state(self) -> bool:
method is_done (line 177) | def is_done(self) -> bool:
method num_steps_taken (line 182) | def num_steps_taken(self) -> int:
method action_names (line 187) | def action_names(self) -> Tuple[str, ...]:
method close (line 211) | def close(self) -> None:
method metrics (line 216) | def metrics(self) -> Dict[str, Any]:
method query_expert (line 233) | def query_expert(self, **kwargs) -> Tuple[Any, bool]:
method cumulative_reward (line 252) | def cumulative_reward(self) -> float:
class TaskSampler (line 269) | class TaskSampler(abc.ABC):
method length (line 274) | def length(self) -> Union[int, float]:
method last_sampled_task (line 286) | def last_sampled_task(self) -> Optional[Task]:
method next_task (line 296) | def next_task(self, force_advance_scene: bool = False) -> Optional[Task]:
method close (line 313) | def close(self) -> None:
method all_observation_spaces_equal (line 322) | def all_observation_spaces_equal(self) -> bool:
method reset (line 340) | def reset(self) -> None:
method set_seed (line 345) | def set_seed(self, seed: int) -> None:
FILE: allenact/embodiedai/aux_losses/losses.py
function _bernoulli_subsample_mask_like (line 28) | def _bernoulli_subsample_mask_like(masks, p=0.1):
class MultiAuxTaskNegEntropyLoss (line 32) | class MultiAuxTaskNegEntropyLoss(AbstractActorCriticLoss):
method __init__ (line 40) | def __init__(self, task_names: Sequence[str], *args, **kwargs):
method loss (line 45) | def loss( # type: ignore
class AuxiliaryLoss (line 72) | class AuxiliaryLoss(AbstractActorCriticLoss):
method __init__ (line 79) | def __init__(self, auxiliary_uuid: str, *args, **kwargs):
method loss (line 84) | def loss( # type: ignore
method get_aux_loss (line 102) | def get_aux_loss(
function _propagate_final_beliefs_to_all_steps (line 116) | def _propagate_final_beliefs_to_all_steps(
class InverseDynamicsLoss (line 146) | class InverseDynamicsLoss(AuxiliaryLoss):
method __init__ (line 154) | def __init__(
method get_aux_loss (line 165) | def get_aux_loss(
class TemporalDistanceLoss (line 251) | class TemporalDistanceLoss(AuxiliaryLoss):
method __init__ (line 258) | def __init__(self, num_pairs: int = 8, epsiode_len_min: int = 5, *args...
method get_aux_loss (line 263) | def get_aux_loss(
class CPCALoss (line 373) | class CPCALoss(AuxiliaryLoss):
method __init__ (line 381) | def __init__(
method get_aux_loss (line 389) | def get_aux_loss(
class CPCASoftMaxLoss (line 567) | class CPCASoftMaxLoss(AuxiliaryLoss):
method __init__ (line 572) | def __init__(
method get_aux_loss (line 588) | def get_aux_loss(
class CPCA1SoftMaxLoss (line 707) | class CPCA1SoftMaxLoss(CPCASoftMaxLoss):
method __init__ (line 710) | def __init__(self, subsample_rate: float = 1, *args, **kwargs):
class CPCA2SoftMaxLoss (line 716) | class CPCA2SoftMaxLoss(CPCASoftMaxLoss):
method __init__ (line 719) | def __init__(self, subsample_rate: float = 1, *args, **kwargs):
class CPCA4SoftMaxLoss (line 725) | class CPCA4SoftMaxLoss(CPCASoftMaxLoss):
method __init__ (line 728) | def __init__(self, subsample_rate: float = 1, *args, **kwargs):
class CPCA8SoftMaxLoss (line 734) | class CPCA8SoftMaxLoss(CPCASoftMaxLoss):
method __init__ (line 737) | def __init__(self, subsample_rate: float = 1, *args, **kwargs):
class CPCA16SoftMaxLoss (line 743) | class CPCA16SoftMaxLoss(CPCASoftMaxLoss):
method __init__ (line 746) | def __init__(self, subsample_rate: float = 1, *args, **kwargs):
class CPCA1Loss (line 755) | class CPCA1Loss(CPCALoss):
method __init__ (line 758) | def __init__(self, subsample_rate: float = 0.2, *args, **kwargs):
class CPCA2Loss (line 764) | class CPCA2Loss(CPCALoss):
method __init__ (line 767) | def __init__(self, subsample_rate: float = 0.2, *args, **kwargs):
class CPCA4Loss (line 773) | class CPCA4Loss(CPCALoss):
method __init__ (line 776) | def __init__(self, subsample_rate: float = 0.2, *args, **kwargs):
class CPCA8Loss (line 782) | class CPCA8Loss(CPCALoss):
method __init__ (line 785) | def __init__(self, subsample_rate: float = 0.2, *args, **kwargs):
class CPCA16Loss (line 791) | class CPCA16Loss(CPCALoss):
method __init__ (line 794) | def __init__(self, subsample_rate: float = 0.2, *args, **kwargs):
FILE: allenact/embodiedai/mapping/mapping_losses.py
class BinnedPointCloudMapLoss (line 12) | class BinnedPointCloudMapLoss(AbstractActorCriticLoss):
method __init__ (line 16) | def __init__(
method loss (line 38) | def loss( # type: ignore
class SemanticMapFocalLoss (line 81) | class SemanticMapFocalLoss(AbstractActorCriticLoss):
method __init__ (line 92) | def __init__(
method loss (line 114) | def loss( # type: ignore
FILE: allenact/embodiedai/mapping/mapping_models/active_neural_slam.py
function _inv_sigmoid (line 39) | def _inv_sigmoid(x: torch.Tensor):
class ActiveNeuralSLAM (line 43) | class ActiveNeuralSLAM(nn.Module):
method __init__ (line 65) | def __init__(
method device (line 234) | def device(self):
method train (line 240) | def train(self, mode: bool = True):
method map_size (line 247) | def map_size(self):
method vision_range (line 251) | def vision_range(self):
method image_to_egocentric_map_logits (line 254) | def image_to_egocentric_map_logits(
method allocentric_map_to_egocentric_view (line 283) | def allocentric_map_to_egocentric_view(
method estimate_egocentric_dx_dz_dr (line 334) | def estimate_egocentric_dx_dz_dr(
method update_allocentric_xzrs_with_egocentric_movement (line 363) | def update_allocentric_xzrs_with_egocentric_movement(
method forward (line 389) | def forward(
function _move_egocentric_map_view_into_allocentric_position (line 536) | def _move_egocentric_map_view_into_allocentric_position(
FILE: allenact/embodiedai/mapping/mapping_utils/map_builders.py
class BinnedPointCloudMapBuilder (line 39) | class BinnedPointCloudMapBuilder(object):
method __init__ (line 71) | def __init__(
method update (line 102) | def update(
method reset (line 298) | def reset(self, min_xyz: np.ndarray):
class ObjectHull2d (line 312) | class ObjectHull2d:
method __init__ (line 313) | def __init__(
class SemanticMapBuilder (line 337) | class SemanticMapBuilder(object):
method __init__ (line 359) | def __init__(
method randomly_color_semantic_map (line 399) | def randomly_color_semantic_map(
method _xzs_to_colrows (line 421) | def _xzs_to_colrows(self, xzs: np.ndarray):
method build_ground_truth_map (line 436) | def build_ground_truth_map(self, object_hulls: Sequence[ObjectHull2d]):
method update (line 457) | def update(
method reset (line 608) | def reset(self, min_xyz: np.ndarray, object_hulls: Sequence[ObjectHull...
FILE: allenact/embodiedai/mapping/mapping_utils/point_cloud_utils.py
function camera_space_xyz_to_world_xyz (line 34) | def camera_space_xyz_to_world_xyz(
function depth_frame_to_camera_space_xyz (line 108) | def depth_frame_to_camera_space_xyz(
function depth_frame_to_world_space_xyz (line 164) | def depth_frame_to_world_space_xyz(
function project_point_cloud_to_map (line 221) | def project_point_cloud_to_map(
function _cpu_only_camera_space_xyz_to_world_xyz (line 336) | def _cpu_only_camera_space_xyz_to_world_xyz(
function _cpu_only_depth_frame_to_camera_space_xyz (line 386) | def _cpu_only_depth_frame_to_camera_space_xyz(
function _cpu_only_depth_frame_to_world_space_xyz (line 425) | def _cpu_only_depth_frame_to_world_space_xyz(
function _cpu_only_project_point_cloud_to_map (line 446) | def _cpu_only_project_point_cloud_to_map(
FILE: allenact/embodiedai/models/aux_models.py
class AuxiliaryModel (line 21) | class AuxiliaryModel(nn.Module):
method __init__ (line 25) | def __init__(
method initialize_model_given_aux_uuid (line 46) | def initialize_model_given_aux_uuid(self, aux_uuid: str):
method init_inverse_dynamics (line 58) | def init_inverse_dynamics(self):
method init_temporal_distance (line 63) | def init_temporal_distance(self):
method init_cpca (line 66) | def init_cpca(self):
method init_cpca_softmax (line 83) | def init_cpca_softmax(self):
method forward (line 105) | def forward(self, features: torch.FloatTensor):
FILE: allenact/embodiedai/models/basic_models.py
class SimpleCNN (line 29) | class SimpleCNN(nn.Module):
method __init__ (line 41) | def __init__(
method make_cnn_from_params (line 113) | def make_cnn_from_params(
method _conv_output_dim (line 156) | def _conv_output_dim(
method layer_init (line 198) | def layer_init(cnn) -> None:
method is_blind (line 207) | def is_blind(self):
method forward (line 212) | def forward(self, observations: Dict[str, torch.Tensor]): # type: ignore
class RNNStateEncoder (line 246) | class RNNStateEncoder(nn.Module):
method __init__ (line 253) | def __init__(
method layer_init (line 290) | def layer_init(self):
method num_recurrent_layers (line 299) | def num_recurrent_layers(self) -> int:
method _pack_hidden (line 303) | def _pack_hidden(
method _unpack_hidden (line 320) | def _unpack_hidden(
method _mask_hidden (line 333) | def _mask_hidden(
method single_forward (line 375) | def single_forward(
method adapt_input (line 414) | def adapt_input(
method adapt_result (line 469) | def adapt_result(
method seq_forward (line 495) | def seq_forward( # type: ignore
method forward (line 567) | def forward( # type: ignore
class LinearActorCritic (line 581) | class LinearActorCritic(ActorCriticModel[CategoricalDistr]):
method __init__ (line 582) | def __init__(
method _recurrent_memory_specification (line 609) | def _recurrent_memory_specification(self):
method forward (line 612) | def forward(self, observations, memory, prev_actions, masks):
class RNNActorCritic (line 628) | class RNNActorCritic(ActorCriticModel[Distr]):
method __init__ (line 629) | def __init__(
method recurrent_hidden_state_size (line 681) | def recurrent_hidden_state_size(self) -> int:
method num_recurrent_layers (line 685) | def num_recurrent_layers(self) -> int:
method _recurrent_memory_specification (line 688) | def _recurrent_memory_specification(self):
method forward (line 700) | def forward( # type:ignore
FILE: allenact/embodiedai/models/fusion_models.py
class Fusion (line 14) | class Fusion(nn.Module):
method __init__ (line 20) | def __init__(self, hidden_size, obs_embed_size, num_tasks):
method forward (line 26) | def forward(
method get_belief_weights (line 52) | def get_belief_weights(
class AverageFusion (line 60) | class AverageFusion(Fusion):
method get_belief_weights (line 63) | def get_belief_weights(
class SoftmaxFusion (line 75) | class SoftmaxFusion(Fusion):
method __init__ (line 81) | def __init__(self, hidden_size, obs_embed_size, num_tasks):
method get_belief_weights (line 87) | def get_belief_weights(
class AttentiveFusion (line 98) | class AttentiveFusion(Fusion):
method __init__ (line 104) | def __init__(self, hidden_size, obs_embed_size, num_tasks):
method get_belief_weights (line 108) | def get_belief_weights(
FILE: allenact/embodiedai/models/resnet.py
function conv3x3 (line 19) | def conv3x3(in_planes, out_planes, stride=1, groups=1):
function conv1x1 (line 32) | def conv1x1(in_planes, out_planes, stride=1):
class BasicBlock (line 37) | class BasicBlock(nn.Module):
method __init__ (line 41) | def __init__(
method forward (line 61) | def forward(self, x):
function _build_bottleneck_branch (line 72) | def _build_bottleneck_branch(inplanes, planes, ngroups, stride, expansio...
class SE (line 85) | class SE(nn.Module):
method __init__ (line 86) | def __init__(self, planes, r=16):
method forward (line 96) | def forward(self, x):
function _build_se_branch (line 105) | def _build_se_branch(planes, r=16):
class Bottleneck (line 109) | class Bottleneck(nn.Module):
method __init__ (line 113) | def __init__(
method _impl (line 134) | def _impl(self, x):
method forward (line 144) | def forward(self, x):
class SEBottleneck (line 148) | class SEBottleneck(Bottleneck):
method __init__ (line 149) | def __init__(
method _impl (line 162) | def _impl(self, x):
class SEResNeXtBottleneck (line 174) | class SEResNeXtBottleneck(SEBottleneck):
class ResNeXtBottleneck (line 179) | class ResNeXtBottleneck(Bottleneck):
class GroupNormResNet (line 184) | class GroupNormResNet(nn.Module):
method __init__ (line 185) | def __init__(self, in_channels, base_planes, ngroups, block, layers, c...
method _make_layer (line 220) | def _make_layer(self, block, ngroups, planes, blocks, stride=1):
method forward (line 244) | def forward(self, x):
function gnresnet18 (line 256) | def gnresnet18(in_channels, base_planes, ngroups):
function gnresnet50 (line 262) | def gnresnet50(in_channels, base_planes, ngroups):
function gnresneXt50 (line 268) | def gnresneXt50(in_channels, base_planes, ngroups):
function se_gnresnet50 (line 281) | def se_gnresnet50(in_channels, base_planes, ngroups):
function se_gnresneXt50 (line 289) | def se_gnresneXt50(in_channels, base_planes, ngroups):
function se_gnresneXt101 (line 302) | def se_gnresneXt101(in_channels, base_planes, ngroups):
class GroupNormResNetEncoder (line 315) | class GroupNormResNetEncoder(nn.Module):
method __init__ (line 316) | def __init__(
method is_blind (line 392) | def is_blind(self):
method layer_init (line 395) | def layer_init(self):
method forward (line 403) | def forward(self, observations):
FILE: allenact/embodiedai/models/visual_nav_models.py
class VisualNavActorCritic (line 29) | class VisualNavActorCritic(ActorCriticModel[CategoricalDistr]):
method __init__ (line 38) | def __init__(
method create_state_encoders (line 68) | def create_state_encoders(
method load_state_dict (line 122) | def load_state_dict(self, state_dict, **kwargs):
method create_actorcritic_head (line 137) | def create_actorcritic_head(self):
method create_aux_models (line 141) | def create_aux_models(self, obs_embed_size: int, action_embed_size: int):
method num_recurrent_layers (line 157) | def num_recurrent_layers(self):
method recurrent_hidden_state_size (line 162) | def recurrent_hidden_state_size(self):
method _recurrent_memory_specification (line 166) | def _recurrent_memory_specification(self):
method forward_encoder (line 179) | def forward_encoder(self, observations: ObservationType) -> torch.Floa...
method fuse_beliefs (line 182) | def fuse_beliefs(
method forward (line 195) | def forward( # type:ignore
FILE: allenact/embodiedai/preprocessors/resnet.py
class ResNetEmbedder (line 13) | class ResNetEmbedder(nn.Module):
method __init__ (line 14) | def __init__(self, resnet, pool=True):
method forward (line 20) | def forward(self, x):
class ResNetPreprocessor (line 40) | class ResNetPreprocessor(Preprocessor):
method __init__ (line 43) | def __init__(
method resnet (line 93) | def resnet(self) -> ResNetEmbedder:
method to (line 100) | def to(self, device: torch.device) -> "ResNetPreprocessor":
method process (line 105) | def process(self, obs: Dict[str, Any], *args: Any, **kwargs: Any) -> Any:
FILE: allenact/embodiedai/sensors/vision_sensors.py
class VisionSensor (line 19) | class VisionSensor(Sensor[EnvType, SubTaskType]):
method __init__ (line 20) | def __init__(
method _make_observation_space (line 95) | def _make_observation_space(
method _get_observation_space (line 137) | def _get_observation_space(self):
method height (line 141) | def height(self) -> Optional[int]:
method width (line 151) | def width(self) -> Optional[int]:
method frame_from_env (line 161) | def frame_from_env(self, env: EnvType, task: Optional[SubTaskType]) ->...
method process_img (line 164) | def process_img(self, img: np.ndarray):
method get_observation (line 200) | def get_observation(
class RGBSensor (line 206) | class RGBSensor(VisionSensor[EnvType, SubTaskType], ABC):
method __init__ (line 207) | def __init__(
class DepthSensor (line 255) | class DepthSensor(VisionSensor[EnvType, SubTaskType], ABC):
method __init__ (line 256) | def __init__(
method get_observation (line 306) | def get_observation( # type: ignore
FILE: allenact/embodiedai/storage/vdr_storage.py
function _index_recursive (line 23) | def _index_recursive(d: Dict, key: Union[str, Tuple[str, ...]]):
class InverseDynamicsVDRLoss (line 31) | class InverseDynamicsVDRLoss(GenericAbstractLoss):
method __init__ (line 32) | def __init__(
method loss (line 44) | def loss(
class DiscreteVisualDynamicsReplayStorage (line 68) | class DiscreteVisualDynamicsReplayStorage(ExperienceStorage, MiniBatchSt...
method __init__ (line 69) | def __init__(
method total_experiences (line 98) | def total_experiences(self):
method set_partition (line 101) | def set_partition(self, index: int, num_parts: int):
method initialize (line 107) | def initialize(self, *, observations: ObservationType, **kwargs):
method batched_experience_generator (line 111) | def batched_experience_generator(self, num_mini_batch: int):
method add (line 135) | def add(
method before_updates (line 211) | def before_updates(self, **kwargs):
method after_updates (line 214) | def after_updates(self, **kwargs):
method to (line 217) | def to(self, device: torch.device):
FILE: allenact/main.py
function get_argument_parser (line 29) | def get_argument_parser():
function get_args (line 335) | def get_args():
function _config_source (line 351) | def _config_source(config_type: Type) -> Dict[str, str]:
function find_sub_modules (line 367) | def find_sub_modules(path: str, module_list: Optional[List] = None):
function load_config (line 383) | def load_config(args) -> Tuple[ExperimentConfig, Dict[str, str]]:
function main (line 463) | def main():
FILE: allenact/setup.py
function parse_req_file (line 7) | def parse_req_file(fname, initial=None):
function get_version (line 44) | def get_version(fname):
function _do_setup (line 59) | def _do_setup():
FILE: allenact/utils/cache_utils.py
function pos_to_str_for_cache (line 7) | def pos_to_str_for_cache(pos: Dict[str, float]) -> str:
function str_to_pos_for_cache (line 11) | def str_to_pos_for_cache(s: str) -> Dict[str, float]:
function get_distance (line 16) | def get_distance(
function get_distance_to_object (line 58) | def get_distance_to_object(
function _get_shortest_path_distance_from_cache (line 96) | def _get_shortest_path_distance_from_cache(
function _get_shortest_path_distance_to_object_from_cache (line 107) | def _get_shortest_path_distance_to_object_from_cache(
function find_nearest_point_in_cache (line 116) | def find_nearest_point_in_cache(
class DynamicDistanceCache (line 134) | class DynamicDistanceCache(object):
method __init__ (line 135) | def __init__(self, rounding: Optional[int] = None):
method find_distance (line 142) | def find_distance(
method invalidate (line 173) | def invalidate(self):
method _pos_to_str (line 176) | def _pos_to_str(self, pos: Dict[str, Any]) -> str:
FILE: allenact/utils/cacheless_frcnn.py
class CachelessAnchorGenerator (line 13) | class CachelessAnchorGenerator(AnchorGenerator):
method forward (line 14) | def forward(self, image_list: Any, feature_maps: Any):
function fasterrcnn_resnet50_fpn (line 34) | def fasterrcnn_resnet50_fpn(
FILE: allenact/utils/experiment_utils.py
function evenly_distribute_count_into_bins (line 54) | def evenly_distribute_count_into_bins(count: int, nbins: int) -> List[int]:
function recursive_update (line 72) | def recursive_update(
class Builder (line 98) | class Builder(tuple, Generic[ToBuildType]):
method __new__ (line 120) | def __new__(
method __repr__ (line 145) | def __repr__(self) -> str:
method __call__ (line 152) | def __call__(self, **kwargs) -> ToBuildType:
class ScalarMeanTracker (line 172) | class ScalarMeanTracker(object):
method __init__ (line 175) | def __init__(self) -> None:
method add_scalars (line 179) | def add_scalars(
method pop_and_reset (line 200) | def pop_and_reset(self) -> Dict[str, float]:
method reset (line 216) | def reset(self):
method sums (line 220) | def sums(self):
method counts (line 223) | def counts(self) -> Dict[str, int]:
method means (line 226) | def means(self) -> Dict[str, float]:
method empty (line 232) | def empty(self):
class LoggingPackage (line 241) | class LoggingPackage:
method __init__ (line 244) | def __init__(
method num_non_empty_metrics_dicts_added (line 271) | def num_non_empty_metrics_dicts_added(self) -> int:
method _metrics_dict_is_empty (line 275) | def _metrics_dict_is_empty(
method add_metrics_dict (line 290) | def add_metrics_dict(
method add_info_dict (line 303) | def add_info_dict(
class LinearDecay (line 318) | class LinearDecay(object):
method __init__ (line 331) | def __init__(self, steps: int, startp: float = 1.0, endp: float = 0.0)...
method __call__ (line 340) | def __call__(self, epoch: int) -> float:
class MultiLinearDecay (line 355) | class MultiLinearDecay(object):
method __init__ (line 367) | def __init__(self, stages: Sequence[LinearDecay]) -> None:
method __call__ (line 380) | def __call__(self, epoch: int) -> float:
function set_deterministic_cudnn (line 405) | def set_deterministic_cudnn() -> None:
function set_seed (line 415) | def set_seed(seed: Optional[int] = None) -> None:
class EarlyStoppingCriterion (line 432) | class EarlyStoppingCriterion(abc.ABC):
method __call__ (line 437) | def __call__(
class NeverEarlyStoppingCriterion (line 457) | class NeverEarlyStoppingCriterion(EarlyStoppingCriterion):
method __call__ (line 460) | def __call__(
class OffPolicyPipelineComponent (line 469) | class OffPolicyPipelineComponent(NamedTuple):
class TrainingSettings (line 496) | class TrainingSettings:
method __init__ (line 532) | def __init__(
method keys (line 550) | def keys(self) -> Tuple[str, ...]:
method has_key (line 553) | def has_key(self, key: str) -> bool:
method set_defaults (line 556) | def set_defaults(self, defaults: "TrainingSettings"):
method __getattr__ (line 560) | def __getattr__(self, item: str):
class StageComponent (line 571) | class StageComponent:
method _validate_training_settings (line 594) | def _validate_training_settings(self, attribute, value: TrainingSettin...
class PipelineStage (line 612) | class PipelineStage:
method __init__ (line 639) | def __init__(
method reset (line 704) | def reset(self):
method change_engine_attributes (line 716) | def change_engine_attributes(self, engine: Any):
method stage_components (line 727) | def stage_components(self) -> Tuple[StageComponent]:
method add_stage_component (line 730) | def add_stage_component(self, stage_component: StageComponent):
method __setattr__ (line 765) | def __setattr__(self, key: str, value: Any):
method is_complete (line 778) | def is_complete(self):
class TrainingPipeline (line 785) | class TrainingPipeline:
method __init__ (line 815) | def __init__(
method _initialize_rollout_storage_uuid (line 901) | def _initialize_rollout_storage_uuid(
method _ensure_pipeline_stages_all_have_at_least_one_stage_component (line 918) | def _ensure_pipeline_stages_all_have_at_least_one_stage_component(self):
method _get_uuids_of_rollout_storages (line 967) | def _get_uuids_of_rollout_storages(
method _initialize_named_storages (line 982) | def _initialize_named_storages(
method _refresh_current_stage (line 999) | def _refresh_current_stage(
method total_steps (line 1019) | def total_steps(self) -> int:
method storage_uuid_to_total_experiences (line 1023) | def storage_uuid_to_total_experiences(self) -> Dict[str, int]:
method current_stage (line 1045) | def current_stage(self) -> Optional[PipelineStage]:
method current_stage_index (line 1049) | def current_stage_index(self) -> Optional[int]:
method before_rollout (line 1054) | def before_rollout(self, train_metrics: Optional[ScalarMeanTracker] = ...
method restart_pipeline (line 1075) | def restart_pipeline(self):
method state_dict (line 1088) | def state_dict(self):
method load_state_dict (line 1102) | def load_state_dict(self, state_dict: Dict[str, Any]):
method rollout_storage (line 1127) | def rollout_storage(self) -> Optional[RolloutStorage]:
method get_stage_storage (line 1138) | def get_stage_storage(
method current_stage_storage (line 1165) | def current_stage_storage(self) -> "OrderedDict[str, ExperienceStorage]":
method get_loss (line 1168) | def get_loss(self, uuid: str):
method current_stage_losses (line 1177) | def current_stage_losses(
function download_checkpoint_from_wandb (line 1196) | def download_checkpoint_from_wandb(
FILE: allenact/utils/inference.py
class InferenceAgent (line 21) | class InferenceAgent:
method __attrs_post_init__ (line 32) | def __attrs_post_init__(self):
method from_experiment_config (line 44) | def from_experiment_config(
method reset (line 88) | def reset(self):
method act (line 94) | def act(self, observations: ObservationType):
FILE: allenact/utils/misc_utils.py
function multiprocessing_safe_download_file_from_url (line 39) | def multiprocessing_safe_download_file_from_url(url: str, save_path: str):
function experimental_api (line 51) | def experimental_api(to_decorate):
function deprecated (line 74) | def deprecated(to_decorate):
class NumpyJSONEncoder (line 95) | class NumpyJSONEncoder(json.JSONEncoder):
method default (line 102) | def default(self, obj):
function tensor_print_options (line 118) | def tensor_print_options(**print_opts):
function md5_hash_str_as_int (line 130) | def md5_hash_str_as_int(to_hash: str):
function get_git_diff_of_project (line 137) | def get_git_diff_of_project() -> Tuple[str, str]:
class HashableDict (line 145) | class HashableDict(dict):
method __init__ (line 155) | def __init__(self, *args, **kwargs):
method __key (line 160) | def __key(self):
method __hash__ (line 163) | def __hash__(self):
method __eq__ (line 167) | def __eq__(self, other):
method __setitem__ (line 170) | def __setitem__(self, *args, **kwargs):
method __delitem__ (line 175) | def __delitem__(self, *args, **kwargs):
function partition_sequence (line 183) | def partition_sequence(seq: Sequence, parts: int) -> List:
function unzip (line 195) | def unzip(seq: Sequence[Tuple], n: Optional[int]):
function uninterleave (line 222) | def uninterleave(seq: Sequence, parts: int) -> List:
function cached_comb (line 235) | def cached_comb(n: int, m: int):
function expected_max_of_subset_statistic (line 239) | def expected_max_of_subset_statistic(vals: List[float], m: int):
function bootstrap_max_of_subset_statistic (line 266) | def bootstrap_max_of_subset_statistic(
function rand_float (line 284) | def rand_float(low: float, high: float, shape):
function all_unique (line 292) | def all_unique(seq: Sequence[Hashable]):
function all_equal (line 301) | def all_equal(s: Sequence):
function prepare_locals_for_super (line 307) | def prepare_locals_for_super(
function partition_limits (line 324) | def partition_limits(num_items: int, num_parts: int):
function str2bool (line 332) | def str2bool(v: str):
class ForkedPdb (line 342) | class ForkedPdb(pdb.Pdb):
method interaction (line 345) | def interaction(self, *args, **kwargs):
FILE: allenact/utils/model_utils.py
function md5_hash_of_state_dict (line 13) | def md5_hash_of_state_dict(state_dict: Dict[str, Any]):
class Flatten (line 34) | class Flatten(nn.Module):
method forward (line 38) | def forward(self, x):
function init_linear_layer (line 49) | def init_linear_layer(
function grad_norm (line 72) | def grad_norm(parameters, norm_type=2):
function make_cnn (line 88) | def make_cnn(
function compute_cnn_output (line 144) | def compute_cnn_output(
function simple_conv_and_linear_weights_init (line 210) | def simple_conv_and_linear_weights_init(m):
function simple_linear_weights_init (line 230) | def simple_linear_weights_init(m):
class FeatureEmbedding (line 241) | class FeatureEmbedding(nn.Module):
method __init__ (line 245) | def __init__(self, input_size, output_size):
method forward (line 261) | def forward(self, inputs):
FILE: allenact/utils/multi_agent_viz_utils.py
class MultiTrajectoryViz (line 10) | class MultiTrajectoryViz(TrajectoryViz):
method __init__ (line 11) | def __init__(
method make_fig (line 29) | def make_fig(self, episode, episode_id):
FILE: allenact/utils/spaces_utils.py
function flatdim (line 16) | def flatdim(space):
function flatten (line 40) | def flatten(space, torch_x):
function unflatten (line 69) | def unflatten(space, torch_x):
function torch_point (line 100) | def torch_point(space, np_x):
function numpy_point (line 120) | def numpy_point(
function flatten_space (line 150) | def flatten_space(space: gym.Space):
function policy_space (line 177) | def policy_space(
function action_list (line 222) | def action_list(
FILE: allenact/utils/system.py
class ColoredFormatter (line 21) | class ColoredFormatter(logging.Formatter):
method __init__ (line 42) | def __init__(self, fmt: str, datefmt: Optional[str] = None, use_color=...
method format (line 46) | def format(self, record: logging.LogRecord) -> str:
function get_logger (line 64) | def get_logger() -> logging.Logger:
function _human_log_level_to_int (line 81) | def _human_log_level_to_int(human_log_level):
function init_logging (line 103) | def init_logging(human_log_level: str = "info") -> None:
function update_log_level (line 114) | def update_log_level(logger, human_log_level: str):
function find_free_port (line 118) | def find_free_port(address: str = "127.0.0.1") -> int:
function _new_logger (line 132) | def _new_logger(log_level: Optional[int] = None):
function _set_log_formatter (line 144) | def _set_log_formatter():
class _StreamToLogger (line 191) | class _StreamToLogger:
method __init__ (line 192) | def __init__(self):
method write (line 195) | def write(self, buf):
method flush (line 204) | def flush(self):
function _excepthook (line 210) | def _excepthook(*args):
class _AllenActMessageFilter (line 215) | class _AllenActMessageFilter:
method __init__ (line 216) | def __init__(self, working_directory: str):
method filter (line 220) | def filter(self, record):
class ImportChecker (line 229) | class ImportChecker:
method __init__ (line 230) | def __init__(self, msg=None):
method __enter__ (line 233) | def __enter__(self):
method __exit__ (line 236) | def __exit__(self, exc_type, value, traceback):
FILE: allenact/utils/tensor_utils.py
function to_device_recursively (line 25) | def to_device_recursively(
function detach_recursively (line 84) | def detach_recursively(input: Any, inplace=True):
function batch_observations (line 130) | def batch_observations(
function to_tensor (line 191) | def to_tensor(v) -> torch.Tensor:
function tile_images (line 212) | def tile_images(images: List[np.ndarray]) -> np.ndarray:
class SummaryWriter (line 242) | class SummaryWriter(TBXSummaryWriter):
method _video (line 244) | def _video(tag, vid):
method add_vid (line 249) | def add_vid(self, tag, vid, global_step=None, walltime=None):
method add_image (line 254) | def add_image(
function image (line 262) | def image(tag, tensor, rescale=1, dataformats="CHW"):
function convert_to_HWC (line 300) | def convert_to_HWC(tensor, input_format): # tensor: numpy array
function make_grid (line 336) | def make_grid(I, ncols=8):
function tensor_to_video (line 359) | def tensor_to_video(tensor, fps=4):
function tensor_to_clip (line 369) | def tensor_to_clip(tensor, fps=4):
function clips_to_video (line 383) | def clips_to_video(clips, h, w, c):
function process_video (line 411) | def process_video(render, max_clip_len=500, max_video_len=-1, fps=4):
class ScaleBothSides (line 463) | class ScaleBothSides(object):
method __init__ (line 472) | def __init__(self, width: int, height: int, interpolation=Image.BILINE...
method __call__ (line 477) | def __call__(self, img: PIL.Image) -> PIL.Image:
FILE: allenact/utils/viz_utils.py
class AbstractViz (line 56) | class AbstractViz:
method __init__ (line 57) | def __init__(
method _source_to_str (line 85) | def _source_to_str(source, is_vector_task):
method _access (line 93) | def _access(dictionary, path):
method _auto_viz_order (line 99) | def _auto_viz_order(self, task_outputs):
method _setup (line 124) | def _setup(
method log (line 144) | def log(
class TrajectoryViz (line 154) | class TrajectoryViz(AbstractViz):
method __init__ (line 155) | def __init__(
method log (line 191) | def log(
method make_fig (line 224) | def make_fig(self, episode, episode_id):
class AgentViewViz (line 321) | class AgentViewViz(AbstractViz):
method __init__ (line 322) | def __init__(
method log (line 356) | def log(
method _overlay_label (line 399) | def _overlay_label(
method make_vid (line 430) | def make_vid(self, images):
class AbstractTensorViz (line 462) | class AbstractTensorViz(AbstractViz):
method __init__ (line 463) | def __init__(
method log (line 483) | def log(
method make_fig (line 528) | def make_fig(
class TensorViz1D (line 534) | class TensorViz1D(AbstractTensorViz):
method __init__ (line 535) | def __init__(
method make_fig (line 544) | def make_fig(self, episode_src, episode_id):
class TensorViz2D (line 560) | class TensorViz2D(AbstractTensorViz):
method __init__ (line 561) | def __init__(
method make_fig (line 572) | def make_fig(self, episode_src, episode_id):
class ActorViz (line 595) | class ActorViz(AbstractViz):
method __init__ (line 596) | def __init__(
method log (line 612) | def log(
method make_fig (line 664) | def make_fig(self, episode_src, episode_id):
class VizSuite (line 693) | class VizSuite(AbstractViz):
method __init__ (line 694) | def __init__(
method _setup_sources (line 740) | def _setup_sources(self):
method _episodes_set (line 796) | def _episodes_set(self, episode_list=None) -> Optional[Set[str]]:
method empty (line 806) | def empty(self):
method _update (line 809) | def _update(self, collected_data):
method _append (line 814) | def _append(self, vector_task_data):
method _collect_actor_critic (line 821) | def _collect_actor_critic(self, actor_critic):
method _collect_rollout (line 868) | def _collect_rollout(self, rollout, alive):
method _collect_vector_task (line 942) | def _collect_vector_task(self, vector_task):
method collect (line 985) | def collect(self, vector_task=None, alive=None, rollout=None, actor_cr...
method read_and_reset (line 1020) | def read_and_reset(self) -> Dict[str, List[Dict[str, Any]]]:
method log (line 1027) | def log(
class TensorboardSummarizer (line 1045) | class TensorboardSummarizer:
method __init__ (line 1048) | def __init__(
method _read_tensorflow_experiment_events (line 1093) | def _read_tensorflow_experiment_events(
method _eval_vs_train_time_steps (line 1129) | def _eval_vs_train_time_steps(self, eval_data, train_data):
method _train_vs_time_steps (line 1160) | def _train_vs_time_steps(self, train_data):
method make_tensorboard_summary (line 1180) | def make_tensorboard_summary(self):
FILE: allenact_plugins/babyai_plugin/babyai_models.py
class BabyAIACModelWrapped (line 22) | class BabyAIACModelWrapped(babyai.model.ACModel):
method __init__ (line 23) | def __init__(
method forward_once (line 74) | def forward_once(self, obs, memory, instr_embedding=None):
method forward_loop (line 138) | def forward_loop(
method forward (line 255) | def forward(
method adapt_inputs (line 471) | def adapt_inputs( # type: ignore
method adapt_result (line 530) | def adapt_result(ac_output, hidden_states, num_steps, num_samplers, nu...
class BabyAIRecurrentACModel (line 571) | class BabyAIRecurrentACModel(ActorCriticModel[CategoricalDistr]):
method __init__ (line 572) | def __init__(
method recurrent_hidden_state_size (line 613) | def recurrent_hidden_state_size(self) -> int:
method num_recurrent_layers (line 617) | def num_recurrent_layers(self):
method _recurrent_memory_specification (line 620) | def _recurrent_memory_specification(self):
method forward (line 632) | def forward( # type:ignore
FILE: allenact_plugins/babyai_plugin/babyai_tasks.py
class BabyAITask (line 18) | class BabyAITask(Task[MiniGridEnv]):
method __init__ (line 19) | def __init__(
method action_space (line 45) | def action_space(self) -> gym.spaces.Discrete:
method render (line 48) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method _step (line 51) | def _step(self, action: int) -> RLStepResult:
method get_observations (line 66) | def get_observations(
method reached_terminal_state (line 73) | def reached_terminal_state(self) -> bool:
method class_action_names (line 77) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 85) | def close(self) -> None:
method _expert_timeout_hander (line 88) | def _expert_timeout_hander(self, signum, frame):
method query_expert (line 91) | def query_expert(self, **kwargs) -> Tuple[Any, bool]:
method metrics (line 116) | def metrics(self) -> Dict[str, Any]:
class BabyAITaskSampler (line 124) | class BabyAITaskSampler(TaskSampler):
method __init__ (line 125) | def __init__(
method length (line 180) | def length(self) -> Union[int, float]:
method total_unique (line 188) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 192) | def last_sampled_task(self) -> Optional[Task]:
method next_task (line 195) | def next_task(self, force_advance_scene: bool = False) -> Optional[Bab...
method close (line 219) | def close(self) -> None:
method all_observation_spaces_equal (line 223) | def all_observation_spaces_equal(self) -> bool:
method reset (line 226) | def reset(self) -> None:
method set_seed (line 230) | def set_seed(self, seed: int) -> None:
FILE: allenact_plugins/babyai_plugin/scripts/download_babyai_expert_demos.py
function get_args (line 26) | def get_args():
FILE: allenact_plugins/babyai_plugin/scripts/truncate_expert_demos.py
function make_small_demos (line 11) | def make_small_demos(dir: str):
FILE: allenact_plugins/clip_plugin/clip_preprocessors.py
class ClipResNetEmbedder (line 14) | class ClipResNetEmbedder(nn.Module):
method __init__ (line 15) | def __init__(self, resnet: CLIP, pool=True, pooling_type="avg"):
method forward (line 34) | def forward(self, x):
class ClipResNetPreprocessor (line 39) | class ClipResNetPreprocessor(Preprocessor):
method __init__ (line 46) | def __init__(
method resnet (line 100) | def resnet(self) -> ClipResNetEmbedder:
method to (line 111) | def to(self, device: torch.device) -> "ClipResNetPreprocessor":
method process (line 116) | def process(self, obs: Dict[str, Any], *args: Any, **kwargs: Any) -> Any:
class ClipViTEmbedder (line 135) | class ClipViTEmbedder(nn.Module):
method __init__ (line 136) | def __init__(self, model: CLIP, class_emb_only: bool = False):
method forward (line 146) | def forward(self, x):
class ClipViTPreprocessor (line 175) | class ClipViTPreprocessor(Preprocessor):
method __init__ (line 182) | def __init__(
method vit (line 231) | def vit(self) -> ClipViTEmbedder:
method to (line 243) | def to(self, device: torch.device) -> "ClipViTPreprocessor":
method process (line 248) | def process(self, obs: Dict[str, Any], *args: Any, **kwargs: Any) -> Any:
FILE: allenact_plugins/gym_plugin/gym_distributions.py
class GaussianDistr (line 6) | class GaussianDistr(torch.distributions.Normal, Distr):
method mode (line 9) | def mode(self) -> torch.FloatTensor:
FILE: allenact_plugins/gym_plugin/gym_environment.py
class GymEnvironment (line 7) | class GymEnvironment(gym.Wrapper):
method __init__ (line 10) | def __init__(self, gym_env_name: str):
method reset (line 15) | def reset(self) -> np.ndarray:
method initial_observation (line 20) | def initial_observation(self) -> np.ndarray:
FILE: allenact_plugins/gym_plugin/gym_models.py
class MemorylessActorCritic (line 15) | class MemorylessActorCritic(ActorCriticModel[GaussianDistr]):
method __init__ (line 19) | def __init__(
method make_mlp_hidden (line 58) | def make_mlp_hidden(nl, *dims):
method _recurrent_memory_specification (line 67) | def _recurrent_memory_specification(self):
method forward (line 70) | def forward( # type:ignore
FILE: allenact_plugins/gym_plugin/gym_sensors.py
class GymBox2DSensor (line 11) | class GymBox2DSensor(Sensor[gym.Env, Task[gym.Env]]):
method __init__ (line 14) | def __init__(
method _get_observation_space (line 26) | def _get_observation_space(self) -> gym.Space:
method get_observation (line 39) | def get_observation(
class GymMuJoCoSensor (line 53) | class GymMuJoCoSensor(Sensor[gym.Env, Task[gym.Env]]):
method __init__ (line 56) | def __init__(self, gym_env_name: str, uuid: str, **kwargs: Any):
method _get_observation_space (line 63) | def _get_observation_space(self) -> gym.Space:
method get_observation (line 97) | def get_observation(
FILE: allenact_plugins/gym_plugin/gym_tasks.py
class GymTask (line 17) | class GymTask(Task[gym.Env]):
method __init__ (line 23) | def __init__(
method action_space (line 38) | def action_space(self) -> gym.spaces.Space:
method render (line 41) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method get_observations (line 46) | def get_observations(
method reached_terminal_state (line 53) | def reached_terminal_state(self) -> bool:
method close (line 56) | def close(self) -> None:
method metrics (line 59) | def metrics(self) -> Dict[str, Any]:
class GymContinuousTask (line 73) | class GymContinuousTask(GymTask):
method class_action_names (line 78) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method _step (line 81) | def _step(self, action: Sequence[float]) -> RLStepResult:
function default_task_selector (line 94) | def default_task_selector(env_name: str) -> type:
function sensor_selector (line 117) | def sensor_selector(env_name: str) -> Sensor:
class GymTaskSampler (line 142) | class GymTaskSampler(TaskSampler):
method __init__ (line 145) | def __init__(
method length (line 231) | def length(self) -> Union[int, float]:
method total_unique (line 239) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 243) | def last_sampled_task(self) -> Optional[Task]:
method next_task (line 246) | def next_task(self, force_advance_scene: bool = False) -> Optional[Gym...
method close (line 298) | def close(self) -> None:
method all_observation_spaces_equal (line 302) | def all_observation_spaces_equal(self) -> bool:
method reset (line 305) | def reset(self) -> None:
method set_seed (line 309) | def set_seed(self, seed: int) -> None:
FILE: allenact_plugins/habitat_plugin/habitat_environment.py
class HabitatEnvironment (line 17) | class HabitatEnvironment:
method __init__ (line 18) | def __init__(self, config: Config, dataset: Dataset, verbose: bool = F...
method scene_name (line 32) | def scene_name(self) -> str:
method current_frame (line 36) | def current_frame(self) -> np.ndarray:
method step (line 40) | def step(self, action_dict: Dict[str, Union[str, int]]) -> Observations:
method get_location (line 45) | def get_location(self) -> Optional[np.ndarray]:
method get_rotation (line 48) | def get_rotation(self) -> Optional[List[float]]:
method get_shortest_path (line 51) | def get_shortest_path(
method get_current_episode (line 58) | def get_current_episode(self) -> HabitatNavigationEpisode:
method start (line 62) | def start(self):
method stop (line 65) | def stop(self):
method reset (line 68) | def reset(self):
method last_action_success (line 72) | def last_action_success(self) -> bool:
method num_episodes (line 77) | def num_episodes(self) -> int:
FILE: allenact_plugins/habitat_plugin/habitat_sensors.py
class RGBSensorHabitat (line 17) | class RGBSensorHabitat(RGBSensor[HabitatEnvironment, Task[HabitatEnviron...
method __init__ (line 19) | def __init__(
method frame_from_env (line 40) | def frame_from_env(
class DepthSensorHabitat (line 46) | class DepthSensorHabitat(DepthSensor[HabitatEnvironment, Task[HabitatEnv...
method __init__ (line 48) | def __init__(
method frame_from_env (line 72) | def frame_from_env(
class TargetCoordinatesSensorHabitat (line 78) | class TargetCoordinatesSensorHabitat(Sensor[HabitatEnvironment, "PointNa...
method __init__ (line 79) | def __init__(
method _get_observation_space (line 88) | def _get_observation_space(self):
method get_observation (line 94) | def get_observation(
class TargetObjectSensorHabitat (line 106) | class TargetObjectSensorHabitat(Sensor[HabitatEnvironment, "ObjectNavTas...
method __init__ (line 107) | def __init__(self, num_objects: int, uuid: str = "target_object_id", *...
method _get_observation_space (line 112) | def _get_observation_space(num_objects: int):
method get_observation (line 115) | def get_observation(
class AgentCoordinatesSensorHabitat (line 127) | class AgentCoordinatesSensorHabitat(Sensor[HabitatEnvironment, "PointNav...
method __init__ (line 128) | def __init__(self, uuid: str = "agent_position_and_rotation", **kwargs...
method _get_observation_space (line 134) | def _get_observation_space():
method get_observation (line 138) | def get_observation(
FILE: allenact_plugins/habitat_plugin/habitat_task_samplers.py
class PointNavTaskSampler (line 14) | class PointNavTaskSampler(TaskSampler):
method __init__ (line 15) | def __init__(
method _create_environment (line 43) | def _create_environment(self) -> HabitatEnvironment:
method length (line 61) | def length(self) -> Union[int, float]:
method total_unique (line 68) | def total_unique(self) -> Union[int, float, None]:
method last_sampled_task (line 72) | def last_sampled_task(self) -> Optional[PointNavTask]:
method close (line 75) | def close(self) -> None:
method all_observation_spaces_equal (line 80) | def all_observation_spaces_equal(self) -> bool:
method next_task (line 87) | def next_task(self, force_advance_scene=False) -> Optional[PointNavTask]:
method reset (line 122) | def reset(self):
method set_seed (line 125) | def set_seed(self, seed: int):
class ObjectNavTaskSampler (line 131) | class ObjectNavTaskSampler(TaskSampler):
method __init__ (line 132) | def __init__(
method _create_environment (line 162) | def _create_environment(self) -> HabitatEnvironment:
method length (line 180) | def length(self) -> Union[int, float]:
method total_unique (line 187) | def total_unique(self) -> Union[int, float, None]:
method last_sampled_task (line 191) | def last_sampled_task(self) -> Optional[ObjectNavTask]:
method close (line 194) | def close(self) -> None:
method all_observation_spaces_equal (line 199) | def all_observation_spaces_equal(self) -> bool:
method next_task (line 206) | def next_task(self, force_advance_scene=False) -> Optional[ObjectNavTa...
method reset (line 246) | def reset(self):
method set_seed (line 249) | def set_seed(self, seed: int):
FILE: allenact_plugins/habitat_plugin/habitat_tasks.py
class HabitatTask (line 28) | class HabitatTask(Task[HabitatEnvironment], ABC):
method __init__ (line 29) | def __init__(
method get_agent_position_and_rotation (line 55) | def get_agent_position_and_rotation(self):
method last_action (line 59) | def last_action(self):
method last_action (line 63) | def last_action(self, value: str):
method last_action_success (line 67) | def last_action_success(self):
method last_action_success (line 71) | def last_action_success(self, value: Optional[bool]):
method render (line 74) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
class PointNavTask (line 83) | class PointNavTask(Task[HabitatEnvironment]):
method __init__ (line 86) | def __init__(
method current_geodesic_dist_to_target (line 118) | def current_geodesic_dist_to_target(self) -> Optional[float]:
method action_space (line 130) | def action_space(self):
method reached_terminal_state (line 133) | def reached_terminal_state(self) -> bool:
method class_action_names (line 137) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 140) | def close(self) -> None:
method _step (line 143) | def _step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method render (line 166) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method _is_goal_in_range (line 170) | def _is_goal_in_range(self) -> bool:
method judge (line 175) | def judge(self) -> float:
method metrics (line 202) | def metrics(self) -> Dict[str, Any]:
method query_expert (line 218) | def query_expert(self, **kwargs) -> Tuple[int, bool]:
class ObjectNavTask (line 234) | class ObjectNavTask(HabitatTask):
method __init__ (line 237) | def __init__(
method action_space (line 278) | def action_space(self):
method reached_terminal_state (line 281) | def reached_terminal_state(self) -> bool:
method class_action_names (line 285) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method action_names (line 288) | def action_names(self, **kwargs) -> Tuple[str, ...]:
method close (line 291) | def close(self) -> None:
method current_geodesic_dist_to_target (line 294) | def current_geodesic_dist_to_target(self) -> Optional[float]:
method _step (line 305) | def _step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method render (line 359) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method _is_goal_in_range (line 363) | def _is_goal_in_range(self) -> bool:
method judge (line 367) | def judge(self) -> float:
method metrics (line 394) | def metrics(self) -> Dict[str, Any]:
method query_expert (line 414) | def query_expert(self, **kwargs) -> Tuple[int, bool]:
FILE: allenact_plugins/habitat_plugin/habitat_utils.py
function construct_env_configs (line 12) | def construct_env_configs(
function construct_env_configs_mp3d (line 77) | def construct_env_configs_mp3d(config: Config) -> List[Config]:
function distribute (line 213) | def distribute(
function get_habitat_config (line 227) | def get_habitat_config(path: str):
FILE: allenact_plugins/habitat_plugin/scripts/agent_demo.py
function transform_rgb_bgr (line 20) | def transform_rgb_bgr(image):
function agent_demo (line 24) | def agent_demo():
FILE: allenact_plugins/habitat_plugin/scripts/make_map.py
function make_map (line 19) | def make_map(env, scene):
function generate_maps (line 33) | def generate_maps():
FILE: allenact_plugins/ithor_plugin/ithor_constants.py
function make_scene_name (line 22) | def make_scene_name(type_ind, scene_num):
FILE: allenact_plugins/ithor_plugin/ithor_environment.py
class IThorEnvironment (line 20) | class IThorEnvironment(object):
method __init__ (line 32) | def __init__(
method scene_name (line 104) | def scene_name(self) -> str:
method current_frame (line 109) | def current_frame(self) -> np.ndarray:
method last_event (line 114) | def last_event(self) -> ai2thor.server.Event:
method started (line 119) | def started(self) -> bool:
method last_action (line 124) | def last_action(self) -> str:
method last_action (line 129) | def last_action(self, value: str) -> None:
method last_action_success (line 137) | def last_action_success(self) -> bool:
method last_action_success (line 142) | def last_action_success(self, value: bool) -> None:
method last_action_return (line 150) | def last_action_return(self) -> Any:
method last_action_return (line 159) | def last_action_return(self, value: Any) -> None:
method start (line 166) | def start(
method stop (line 212) | def stop(self) -> None:
method reset (line 221) | def reset(
method teleport_agent_to (line 273) | def teleport_agent_to(
method random_reachable_state (line 378) | def random_reachable_state(self, seed: int = None) -> Dict:
method randomize_agent_location (line 390) | def randomize_agent_location(
method object_pixels_in_frame (line 418) | def object_pixels_in_frame(
method object_pixels_on_grid (line 454) | def object_pixels_on_grid(
method object_in_hand (line 494) | def object_in_hand(self):
method initially_reachable_points (line 507) | def initially_reachable_points(self) -> List[Dict[str, float]]:
method initially_reachable_points_set (line 514) | def initially_reachable_points_set(self) -> Set[Tuple[float, float]]:
method currently_reachable_points (line 527) | def currently_reachable_points(self) -> List[Dict[str, float]]:
method get_agent_location (line 533) | def get_agent_location(self) -> Dict[str, Union[float, bool]]:
method _agent_location_to_tuple (line 547) | def _agent_location_to_tuple(p: Dict[str, float]) -> Tuple[float, float]:
method _snap_agent_to_initially_reachable (line 550) | def _snap_agent_to_initially_reachable(self, verbose=True):
method step (line 648) | def step(
method position_dist (line 733) | def position_dist(
method rotation_dist (line 754) | def rotation_dist(a: Dict[str, float], b: Dict[str, float]):
method angle_between_rotations (line 764) | def angle_between_rotations(a: Dict[str, float], b: Dict[str, float]):
method closest_object_with_properties (line 773) | def closest_object_with_properties(
method closest_visible_object_of_type (line 794) | def closest_visible_object_of_type(
method closest_object_of_type (line 802) | def closest_object_of_type(self, object_type: str) -> Optional[Dict[st...
method closest_reachable_point_to_position (line 807) | def closest_reachable_point_to_position(
method _angle_from_to (line 826) | def _angle_from_to(a_from: float, a_to: float) -> float:
method agent_xz_to_scene_xz (line 840) | def agent_xz_to_scene_xz(self, agent_xz: Dict[str, float]) -> Dict[str...
method scene_xz_to_agent_xz (line 865) | def scene_xz_to_agent_xz(self, scene_xz: Dict[str, float]) -> Dict[str...
method all_objects (line 888) | def all_objects(self) -> List[Dict[str, Any]]:
method all_objects_with_properties (line 892) | def all_objects_with_properties(
method visible_objects (line 907) | def visible_objects(self) -> List[Dict[str, Any]]:
method get_object_by_id (line 911) | def get_object_by_id(self, object_id: str) -> Optional[Dict[str, Any]]:
method reachable_points_with_rotations_and_horizons (line 924) | def reachable_points_with_rotations_and_horizons(self):
method location_for_key (line 941) | def location_for_key(key, y_value=0.0):
method get_key (line 947) | def get_key(input_dict: Dict[str, Any]) -> Tuple[float, float, int, int]:
method update_graph_with_failed_action (line 966) | def update_graph_with_failed_action(self, failed_action: str):
method _add_from_to_edge (line 985) | def _add_from_to_edge(
method possible_neighbor_offsets (line 1031) | def possible_neighbor_offsets(self) -> Tuple[Tuple[float, float, int, ...
method _add_node_to_graph (line 1044) | def _add_node_to_graph(self, graph: nx.DiGraph, s: Tuple[float, float,...
method graph (line 1058) | def graph(self):
method graph (line 1069) | def graph(self, g):
method _check_contains_key (line 1072) | def _check_contains_key(self, key: Tuple[float, float, int, int], add_...
method shortest_state_path (line 1080) | def shortest_state_path(self, source_state_key, goal_state_key):
method action_transitioning_between_keys (line 1090) | def action_transitioning_between_keys(self, s, t):
method shortest_path_next_state (line 1098) | def shortest_path_next_state(self, source_state_key, goal_state_key):
method shortest_path_next_action (line 1106) | def shortest_path_next_action(self, source_state_key, goal_state_key):
method shortest_path_length (line 1113) | def shortest_path_length(self, source_state_key, goal_state_key):
FILE: allenact_plugins/ithor_plugin/ithor_sensors.py
class RGBSensorThor (line 36) | class RGBSensorThor(RGBSensor[THOR_ENV_TYPE, THOR_TASK_TYPE]):
method frame_from_env (line 43) | def frame_from_env(
class GoalObjectTypeThorSensor (line 54) | class GoalObjectTypeThorSensor(Sensor):
method __init__ (line 55) | def __init__(
method _get_observation_space (line 91) | def _get_observation_space(self):
method get_observation (line 97) | def get_observation(
class TakeEndActionThorNavSensor (line 107) | class TakeEndActionThorNavSensor(
method __init__ (line 113) | def __init__(self, nactions: int, uuid: str, **kwargs: Any) -> None:
method _get_observation_space (line 120) | def _get_observation_space(self) -> gym.spaces.Discrete:
method get_observation (line 129) | def get_observation( # type:ignore
class RelativePositionChangeTHORSensor (line 150) | class RelativePositionChangeTHORSensor(
method __init__ (line 153) | def __init__(self, uuid: str = "rel_position_change", **kwargs: Any):
method get_relative_position_change (line 175) | def get_relative_position_change(from_xzr: np.ndarray, to_xzr: np.ndar...
method get_observation (line 200) | def get_observation(
class ReachableBoundsTHORSensor (line 228) | class ReachableBoundsTHORSensor(Sensor[RoboThorEnvironment, Task[RoboTho...
method __init__ (line 229) | def __init__(self, margin: float, uuid: str = "scene_bounds", **kwargs...
method get_bounds (line 252) | def get_bounds(
method get_observation (line 267) | def get_observation(
class SceneBoundsTHORSensor (line 288) | class SceneBoundsTHORSensor(Sensor[RoboThorEnvironment, Task[RoboThorEnv...
method __init__ (line 289) | def __init__(self, uuid: str = "scene_bounds", **kwargs: Any):
method get_observation (line 308) | def get_observation(
class BinnedPointCloudMapTHORSensor (line 329) | class BinnedPointCloudMapTHORSensor(
method __init__ (line 334) | def __init__(
method device (line 399) | def device(self):
method device (line 403) | def device(self, val: torch.device):
method get_observation (line 406) | def get_observation(
class SemanticMapTHORSensor (line 453) | class SemanticMapTHORSensor(Sensor[RoboThorEnvironment, Task[RoboThorEnv...
method __init__ (line 456) | def __init__(
method device (line 522) | def device(self):
method device (line 526) | def device(self, val: torch.device):
method get_observation (line 529) | def get_observation(
FILE: allenact_plugins/ithor_plugin/ithor_task_samplers.py
class ObjectNavTaskSampler (line 15) | class ObjectNavTaskSampler(TaskSampler):
method __init__ (line 16) | def __init__(
method _create_environment (line 58) | def _create_environment(self) -> IThorEnvironment:
method length (line 68) | def length(self) -> Union[int, float]:
method total_unique (line 78) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 82) | def last_sampled_task(self) -> Optional[ObjectNaviThorGridTask]:
method close (line 85) | def close(self) -> None:
method all_observation_spaces_equal (line 90) | def all_observation_spaces_equal(self) -> bool:
method sample_scene (line 100) | def sample_scene(self, force_advance_scene: bool):
method next_task (line 141) | def next_task(
method reset (line 190) | def reset(self):
method set_seed (line 197) | def set_seed(self, seed: int):
FILE: allenact_plugins/ithor_plugin/ithor_tasks.py
class ObjectNaviThorGridTask (line 24) | class ObjectNaviThorGridTask(Task[IThorEnvironment]):
method __init__ (line 62) | def __init__(
method action_space (line 87) | def action_space(self):
method reached_terminal_state (line 90) | def reached_terminal_state(self) -> bool:
method class_action_names (line 94) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 97) | def close(self) -> None:
method _step (line 100) | def _step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method render (line 129) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method is_goal_object_visible (line 133) | def is_goal_object_visible(self) -> bool:
method judge (line 140) | def judge(self) -> float:
method metrics (line 152) | def metrics(self) -> Dict[str, Any]:
method query_expert (line 161) | def query_expert(self, **kwargs) -> Tuple[int, bool]:
FILE: allenact_plugins/ithor_plugin/ithor_util.py
function include_object_data (line 16) | def include_object_data(controller: ai2thor.controller.Controller):
function vertical_to_horizontal_fov (line 29) | def vertical_to_horizontal_fov(
function horizontal_to_vertical_fov (line 42) | def horizontal_to_vertical_fov(
function round_to_factor (line 52) | def round_to_factor(num: float, base: int) -> int:
function get_open_x_displays (line 65) | def get_open_x_displays(throw_error_if_empty: bool = False) -> Sequence[...
FILE: allenact_plugins/ithor_plugin/ithor_viz.py
class ThorPositionTo2DFrameTranslator (line 23) | class ThorPositionTo2DFrameTranslator(object):
method __init__ (line 24) | def __init__(
method __call__ (line 34) | def __call__(self, position: Sequence[float]):
class ThorViz (line 50) | class ThorViz(TrajectoryViz):
method __init__ (line 51) | def __init__(
method init_top_down_render (line 99) | def init_top_down_render(self):
method iterate_scenes (line 109) | def iterate_scenes(
method cached_map_data_path (line 117) | def cached_map_data_path(self, roomname: str) -> str:
method get_translator (line 120) | def get_translator(self) -> Dict[str, Any]:
method cached_image_path (line 147) | def cached_image_path(self, roomname: str) -> str:
method make_top_down_views (line 152) | def make_top_down_views(self) -> Dict[str, np.ndarray]:
method crop_viz_image (line 163) | def crop_viz_image(self, viz_image: np.ndarray) -> np.ndarray:
method make_controller (line 172) | def make_controller(self):
method get_agent_map_data (line 185) | def get_agent_map_data(self):
method position_to_tuple (line 197) | def position_to_tuple(position: Dict[str, float]) -> Tuple[float, floa...
method add_lines_to_map (line 201) | def add_lines_to_map(
method add_line_to_map (line 230) | def add_line_to_map(
method add_agent_view_triangle (line 258) | def add_agent_view_triangle(
method visualize_agent_path (line 292) | def visualize_agent_path(
method dump_top_down_view (line 346) | def dump_top_down_view(self, room_name: str, image_path: str):
method make_fig (line 358) | def make_fig(self, episode: Any, episode_id: str) -> Figure:
class ThorMultiViz (line 386) | class ThorMultiViz(ThorViz):
method __init__ (line 387) | def __init__(
method make_fig (line 404) | def make_fig(self, episode: Any, episode_id: str) -> Figure:
FILE: allenact_plugins/lighthouse_plugin/lighthouse_environment.py
function _get_world_corners (line 19) | def _get_world_corners(world_dim: int, world_radius: int):
function _base_world_tensor (line 39) | def _base_world_tensor(world_dim: int, world_radius: int):
class LightHouseEnvironment (line 56) | class LightHouseEnvironment(object):
method __init__ (line 63) | def __init__(self, world_dim: int, world_radius: int, **kwargs):
method set_seed (line 91) | def set_seed(self, seed: int):
method random_reset (line 101) | def random_reset(self, goal_position: Optional[bool] = None):
method step (line 129) | def step(self, action: int) -> bool:
method render (line 151) | def render(self, mode="array", **kwargs):
method close (line 256) | def close(self):
method optimal_ave_ep_length (line 264) | def optimal_ave_ep_length(world_dim: int, world_radius: int, view_radi...
FILE: allenact_plugins/lighthouse_plugin/lighthouse_models.py
class LinearAdvisorActorCritic (line 17) | class LinearAdvisorActorCritic(ActorCriticModel[CategoricalDistr]):
method __init__ (line 18) | def __init__(
method _recurrent_memory_specification (line 52) | def _recurrent_memory_specification(self):
method forward (line 55) | def forward( # type:ignore
FILE: allenact_plugins/lighthouse_plugin/lighthouse_sensors.py
function get_corner_observation (line 16) | def get_corner_observation(
class CornerSensor (line 76) | class CornerSensor(Sensor[LightHouseEnvironment, Any]):
method __init__ (line 77) | def __init__(
method _get_observation_space (line 92) | def _get_observation_space(self):
method get_observation (line 100) | def get_observation(
class FactorialDesignCornerSensor (line 119) | class FactorialDesignCornerSensor(Sensor[LightHouseEnvironment, Any]):
method __init__ (line 122) | def __init__(
method _get_observation_space (line 177) | def _get_observation_space(self):
method view_tuple_to_design_array (line 191) | def view_tuple_to_design_array(self, view_tuple: Tuple):
method output_dim (line 197) | def output_dim(cls, world_dim: int):
method _create_full_design_matrix_and_tuple_to_ind_dict (line 203) | def _create_full_design_matrix_and_tuple_to_ind_dict(
method _get_variables_and_levels (line 241) | def _get_variables_and_levels(world_dim: int):
method _create_formula (line 252) | def _create_formula(
method get_observation (line 272) | def get_observation(
FILE: allenact_plugins/lighthouse_plugin/lighthouse_tasks.py
class LightHouseTask (line 24) | class LightHouseTask(Task[LightHouseEnvironment], abc.ABC):
method __init__ (line 36) | def __init__(
method last_action (line 55) | def last_action(self) -> int:
method last_action (line 59) | def last_action(self, value: int):
method step (line 62) | def step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method render (line 69) | def render(self, mode: str = "array", *args, **kwargs) -> np.ndarray:
class FindGoalLightHouseTask (line 94) | class FindGoalLightHouseTask(LightHouseTask):
method __init__ (line 97) | def __init__(
method action_space (line 110) | def action_space(self) -> gym.spaces.Discrete:
method _step (line 113) | def _step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method reached_terminal_state (line 133) | def reached_terminal_state(self) -> bool:
method class_action_names (line 137) | def class_action_names(cls, world_dim: int = 2, **kwargs) -> Tuple[str...
method action_names (line 150) | def action_names(self) -> Tuple[str, ...]:
method close (line 153) | def close(self) -> None:
method query_expert (line 156) | def query_expert(
class FindGoalLightHouseTaskSampler (line 311) | class FindGoalLightHouseTaskSampler(TaskSampler):
method __init__ (line 312) | def __init__(
method world_dim (line 370) | def world_dim(self):
method world_radius (line 374) | def world_radius(self):
method length (line 378) | def length(self) -> Union[int, float]:
method total_unique (line 386) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 391) | def last_sampled_task(self) -> Optional[Task]:
method next_task (line 394) | def next_task(self, force_advance_scene: bool = False) -> Optional[Task]:
method close (line 416) | def close(self) -> None:
method all_observation_spaces_equal (line 420) | def all_observation_spaces_equal(self) -> bool:
method reset (line 423) | def reset(self) -> None:
method set_seed (line 427) | def set_seed(self, seed: int) -> None:
FILE: allenact_plugins/lighthouse_plugin/lighthouse_util.py
class StopIfNearOptimal (line 6) | class StopIfNearOptimal(EarlyStoppingCriterion):
method __init__ (line 7) | def __init__(self, optimal: float, deviation: float, min_memory_size: ...
method __call__ (line 15) | def __call__(
FILE: allenact_plugins/manipulathor_plugin/arm_calculation_utils.py
function state_dict_to_tensor (line 13) | def state_dict_to_tensor(state: Dict):
function diff_position (line 30) | def diff_position(state_goal, state_curr, absolute: bool = True):
function coord_system_transform (line 40) | def coord_system_transform(position: Dict, coord_system: str):
function position_rotation_to_matrix (line 84) | def position_rotation_to_matrix(position, rotation):
function inverse_rot_trans_matrix (line 93) | def inverse_rot_trans_matrix(mat):
function matrix_to_position_rotation (line 98) | def matrix_to_position_rotation(matrix):
function find_closest_inverse (line 108) | def find_closest_inverse(deg, use_cache):
function calc_inverse (line 122) | def calc_inverse(deg):
function world_coords_to_agent_coords (line 133) | def world_coords_to_agent_coords(world_obj, agent_state, use_cache=True):
FILE: allenact_plugins/manipulathor_plugin/armpointnav_constants.py
function get_agent_start_positions (line 22) | def get_agent_start_positions():
FILE: allenact_plugins/manipulathor_plugin/manipulathor_environment.py
function position_distance (line 46) | def position_distance(s1, s2, filter_nan: bool = False):
function rotation_distance (line 59) | def rotation_distance(s1: Dict[str, Dict[str, float]], s2: Dict[str, Dic...
class ManipulaTHOREnvironment (line 71) | class ManipulaTHOREnvironment(IThorEnvironment):
method __init__ (line 83) | def __init__(
method create_controller (line 137) | def create_controller(self):
method start (line 142) | def start(
method reset (line 168) | def reset(
method randomize_agent_location (line 208) | def randomize_agent_location(
method is_object_at_low_level_hand (line 213) | def is_object_at_low_level_hand(self, object_id):
method object_in_hand (line 219) | def object_in_hand(self):
method correct_nan_inf (line 232) | def correct_nan_inf(cls, flawed_dict, extra_tag=""):
method get_object_by_id (line 239) | def get_object_by_id(self, object_id: str) -> Optional[Dict[str, Any]]:
method get_current_arm_state (line 246) | def get_current_arm_state(self):
method get_absolute_hand_state (line 263) | def get_absolute_hand_state(self):
method get_pickupable_objects (line 272) | def get_pickupable_objects(self):
method get_current_object_locations (line 279) | def get_current_object_locations(self):
method close_enough (line 290) | def close_enough(self, current_obj_pose, init_obj_pose, threshold):
method get_objects_moved (line 299) | def get_objects_moved(
method get_objects_move_distance (line 328) | def get_objects_move_distance(
method step (line 374) | def step(
FILE: allenact_plugins/manipulathor_plugin/manipulathor_sensors.py
class DepthSensorThor (line 23) | class DepthSensorThor(
method frame_from_env (line 35) | def frame_from_env(
class NoVisionSensorThor (line 41) | class NoVisionSensorThor(
method frame_from_env (line 53) | def frame_from_env(
class AgentRelativeCurrentObjectStateThorSensor (line 59) | class AgentRelativeCurrentObjectStateThorSensor(Sensor):
method __init__ (line 60) | def __init__(self, uuid: str = "relative_current_obj_state", **kwargs:...
method get_observation (line 66) | def get_observation(
class RelativeObjectToGoalSensor (line 83) | class RelativeObjectToGoalSensor(Sensor):
method __init__ (line 84) | def __init__(
method get_observation (line 106) | def get_observation(
class InitialObjectToGoalSensor (line 127) | class InitialObjectToGoalSensor(Sensor):
method __init__ (line 128) | def __init__(self, uuid: str = "initial_obj_to_goal", **kwargs: Any):
method get_observation (line 135) | def get_observation(
class DistanceObjectToGoalSensor (line 151) | class DistanceObjectToGoalSensor(Sensor):
method __init__ (line 152) | def __init__(self, uuid: str = "distance_obj_to_goal", **kwargs: Any):
method get_observation (line 159) | def get_observation(
class RelativeAgentArmToObjectSensor (line 177) | class RelativeAgentArmToObjectSensor(Sensor):
method __init__ (line 178) | def __init__(
method get_observation (line 200) | def get_observation(
class InitialAgentArmToObjectSensor (line 222) | class InitialAgentArmToObjectSensor(Sensor):
method __init__ (line 223) | def __init__(self, uuid: str = "initial_agent_arm_to_obj", **kwargs: A...
method get_observation (line 229) | def get_observation(
class DistanceAgentArmToObjectSensor (line 248) | class DistanceAgentArmToObjectSensor(Sensor):
method __init__ (line 249) | def __init__(self, uuid: str = "distance_agent_arm_to_obj", **kwargs: ...
method get_observation (line 255) | def get_observation(
class PickedUpObjSensor (line 275) | class PickedUpObjSensor(Sensor):
method __init__ (line 276) | def __init__(self, uuid: str = "pickedup_object", **kwargs: Any):
method get_observation (line 282) | def get_observation(
FILE: allenact_plugins/manipulathor_plugin/manipulathor_task_samplers.py
class AbstractMidLevelArmTaskSampler (line 33) | class AbstractMidLevelArmTaskSampler(TaskSampler):
method __init__ (line 37) | def __init__(
method _create_environment (line 89) | def _create_environment(self, **kwargs) -> ManipulaTHOREnvironment:
method last_sampled_task (line 99) | def last_sampled_task(self) -> Optional[Task]:
method close (line 102) | def close(self) -> None:
method all_observation_spaces_equal (line 107) | def all_observation_spaces_equal(self) -> bool:
method reset (line 117) | def reset(self):
method set_seed (line 126) | def set_seed(self, seed: int):
class SimpleArmPointNavGeneralSampler (line 132) | class SimpleArmPointNavGeneralSampler(AbstractMidLevelArmTaskSampler):
method __init__ (line 136) | def __init__(self, **kwargs) -> None:
method next_task (line 208) | def next_task(
method total_unique (line 291) | def total_unique(self) -> Optional[Union[int, float]]:
method length (line 298) | def length(self) -> Union[int, float]:
method get_source_target_indices (line 311) | def get_source_target_indices(self):
method calc_possible_trajectories (line 328) | def calc_possible_trajectories(self, all_possible_points):
class ArmPointNavTaskSampler (line 340) | class ArmPointNavTaskSampler(SimpleArmPointNavGeneralSampler):
method __init__ (line 343) | def __init__(self, **kwargs) -> None:
method next_task (line 356) | def next_task(
method get_source_target_indices (line 449) | def get_source_target_indices(self):
class RotateArmPointNavTaskSampler (line 510) | class RotateArmPointNavTaskSampler(ArmPointNavTaskSampler):
class CamRotateArmPointNavTaskSampler (line 514) | class CamRotateArmPointNavTaskSampler(ArmPointNavTaskSampler):
class EasyArmPointNavTaskSampler (line 518) | class EasyArmPointNavTaskSampler(ArmPointNavTaskSampler):
function get_all_tuples_from_list (line 522) | def get_all_tuples_from_list(list):
FILE: allenact_plugins/manipulathor_plugin/manipulathor_tasks.py
class AbstractPickUpDropOffTask (line 46) | class AbstractPickUpDropOffTask(Task[ManipulaTHOREnvironment]):
method __init__ (line 69) | def __init__(
method action_space (line 108) | def action_space(self):
method reached_terminal_state (line 111) | def reached_terminal_state(self) -> bool:
method class_action_names (line 115) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 118) | def close(self) -> None:
method obj_state_aproximity (line 121) | def obj_state_aproximity(self, s1, s2):
method start_visualize (line 132) | def start_visualize(self):
method visualize (line 140) | def visualize(self, action_str):
method finish_visualizer (line 145) | def finish_visualizer(self):
method finish_visualizer_metrics (line 150) | def finish_visualizer_metrics(self, metric_results):
method render (line 155) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method calc_action_stat_metrics (line 159) | def calc_action_stat_metrics(self) -> Dict[str, Any]:
method metrics (line 186) | def metrics(self) -> Dict[str, Any]:
method _step (line 238) | def _step(self, action: int) -> RLStepResult:
method arm_distance_from_obj (line 241) | def arm_distance_from_obj(self):
method obj_distance_from_goal (line 247) | def obj_distance_from_goal(self):
method get_original_object_distance (line 253) | def get_original_object_distance(self):
method judge (line 261) | def judge(self) -> float:
class ArmPointNavTask (line 266) | class ArmPointNavTask(AbstractPickUpDropOffTask):
method __init__ (line 283) | def __init__(
method metrics (line 307) | def metrics(self) -> Dict[str, Any]:
method visualize (line 321) | def visualize(self, **kwargs):
method _step (line 326) | def _step(self, action: int) -> RLStepResult:
method judge (line 369) | def judge(self) -> float:
class RotateArmPointNavTask (line 454) | class RotateArmPointNavTask(ArmPointNavTask):
class CamRotateArmPointNavTask (line 478) | class CamRotateArmPointNavTask(ArmPointNavTask):
class EasyArmPointNavTask (line 504) | class EasyArmPointNavTask(ArmPointNavTask):
method _step (line 521) | def _step(self, action: int) -> RLStepResult:
FILE: allenact_plugins/manipulathor_plugin/manipulathor_utils.py
function make_all_objects_unbreakable (line 12) | def make_all_objects_unbreakable(controller):
function reset_environment_and_additional_commands (line 23) | def reset_environment_and_additional_commands(controller, scene_name):
function transport_wrapper (line 31) | def transport_wrapper(controller, target_object, target_location):
function initialize_arm (line 51) | def initialize_arm(controller):
FILE: allenact_plugins/manipulathor_plugin/manipulathor_viz.py
class LoggerVisualizer (line 20) | class LoggerVisualizer:
method __init__ (line 21) | def __init__(self, exp_name="", log_dir=""):
method log (line 37) | def log(self, environment, action_str):
method is_empty (line 40) | def is_empty(self):
method finish_episode_metrics (line 43) | def finish_episode_metrics(self, episode_info, task_info, metric_resul...
method finish_episode (line 46) | def finish_episode(self, environment, episode_info, task_info):
class TestMetricLogger (line 50) | class TestMetricLogger(LoggerVisualizer):
method __init__ (line 51) | def __init__(self, exp_name="", log_dir="", **kwargs):
method average_dict (line 58) | def average_dict(self):
method finish_episode_metrics (line 64) | def finish_episode_metrics(self, episode_info, task_info, metric_resul...
method log (line 99) | def log(self, environment, action_str="", disturbance_str=""):
class BringObjImageVisualizer (line 105) | class BringObjImageVisualizer(LoggerVisualizer):
method finish_episode (line 106) | def finish_episode(self, environment, episode_info, task_info):
method log (line 159) | def log(self, environment, action_str):
method log_start_goal (line 164) | def log_start_goal(self, env, task_info, tag, img_adr):
class ImageVisualizer (line 220) | class ImageVisualizer(LoggerVisualizer):
method __init__ (line 221) | def __init__(
method finish_episode (line 235) | def finish_episode(self, environment, episode_info, task_info):
method log (line 305) | def log(self, environment, action_str="", disturbance_str=""):
method log_start_goal (line 320) | def log_start_goal(self, env, task_info, tag, img_adr):
function save_image_list_to_gif (line 375) | def save_image_list_to_gif(image_list, gif_name, gif_dir):
function put_annotation_on_image (line 393) | def put_annotation_on_image(images, annotations):
FILE: allenact_plugins/minigrid_plugin/configs/minigrid_nomemory.py
class MiniGridNoMemoryExperimentConfig (line 12) | class MiniGridNoMemoryExperimentConfig(MiniGridTutorialExperimentConfig):
method tag (line 14) | def tag(cls) -> str:
method create_model (line 18) | def create_model(cls, **kwargs) -> nn.Module:
FILE: allenact_plugins/minigrid_plugin/minigrid_environments.py
class FastCrossing (line 10) | class FastCrossing(CrossingEnv):
method __init__ (line 14) | def __init__(self, size=9, num_crossings=1, obstacle_type=Lava, seed=N...
method same_seed_reset (line 25) | def same_seed_reset(self):
method reset (line 45) | def reset(self, partial_reset: bool = False):
class AskForHelpSimpleCrossing (line 51) | class AskForHelpSimpleCrossing(CrossingEnv):
method __init__ (line 54) | def __init__(
method was_successful (line 84) | def was_successful(self) -> bool:
method gen_obs (line 87) | def gen_obs(self):
method metrics (line 93) | def metrics(self):
method step (line 104) | def step(self, action: int):
method same_seed_reset (line 136) | def same_seed_reset(self):
method reset (line 161) | def reset(self, partial_reset: bool = False):
class LavaCrossingS25N10 (line 171) | class LavaCrossingS25N10(CrossingEnv):
method __init__ (line 172) | def __init__(self):
class LavaCrossingS15N7 (line 176) | class LavaCrossingS15N7(CrossingEnv):
method __init__ (line 177) | def __init__(self):
class LavaCrossingS11N7 (line 181) | class LavaCrossingS11N7(CrossingEnv):
method __init__ (line 182) | def __init__(self):
FILE: allenact_plugins/minigrid_plugin/minigrid_models.py
class MiniGridSimpleConvBase (line 22) | class MiniGridSimpleConvBase(ActorCriticModel[Distr], abc.ABC):
method __init__ (line 25) | def __init__(
method forward (line 86) | def forward( # type:ignore
class MiniGridSimpleConvRNN (line 141) | class MiniGridSimpleConvRNN(MiniGridSimpleConvBase):
method __init__ (line 142) | def __init__(
method num_recurrent_layers (line 191) | def num_recurrent_layers(self):
method recurrent_hidden_state_size (line 195) | def recurrent_hidden_state_size(self):
method _recurrent_memory_specification (line 198) | def _recurrent_memory_specification(self):
class MiniGridSimpleConv (line 211) | class MiniGridSimpleConv(MiniGridSimpleConvBase):
method __init__ (line 212) | def __init__(
method num_recurrent_layers (line 250) | def num_recurrent_layers(self):
method recurrent_hidden_state_size (line 254) | def recurrent_hidden_state_size(self):
method _recurrent_memory_specification (line 258) | def _recurrent_memory_specification(self):
FILE: allenact_plugins/minigrid_plugin/minigrid_offpolicy.py
class MiniGridOffPolicyExpertCELoss (line 28) | class MiniGridOffPolicyExpertCELoss(GenericAbstractLoss):
method __init__ (line 29) | def __init__(self, total_episodes_in_epoch: Optional[int] = None):
method loss (line 33) | def loss( # type: ignore
function transform_demos (line 91) | def transform_demos(demos):
class MiniGridExpertTrajectoryStorage (line 125) | class MiniGridExpertTrajectoryStorage(ExperienceStorage, StreamingStorag...
method __init__ (line 126) | def __init__(
method data (line 163) | def data(self) -> List[Tuple[str, bytes, List[int], MiniGridEnv.Action...
method set_partition (line 203) | def set_partition(self, index: int, num_parts: int):
method initialize (line 219) | def initialize(self, *, observations: ObservationType, **kwargs):
method add (line 223) | def add(
method to (line 235) | def to(self, device: torch.device):
method total_experiences (line 239) | def total_experiences(self) -> int:
method reset_stream (line 242) | def reset_stream(self):
method empty (line 245) | def empty(self) -> bool:
method _get_next_ind (line 248) | def _get_next_ind(self):
method _fill_rollout_queue (line 254) | def _fill_rollout_queue(self, q: queue.Queue, sampler: int):
method get_data_for_rollout_ind (line 266) | def get_data_for_rollout_ind(self, sampler_ind: int) -> Dict[str, np.n...
method next_batch (line 319) | def next_batch(self) -> Dict[str, torch.Tensor]:
FILE: allenact_plugins/minigrid_plugin/minigrid_sensors.py
class EgocentricMiniGridSensor (line 24) | class EgocentricMiniGridSensor(Sensor[MiniGridEnv, Task[MiniGridEnv]]):
method __init__ (line 25) | def __init__(
method _get_observation_space (line 53) | def _get_observation_space(self) -> gym.Space:
method get_observation (line 61) | def get_observation(
class MiniGridMissionSensor (line 82) | class MiniGridMissionSensor(Sensor[MiniGridEnv, Task[MiniGridEnv]]):
method __init__ (line 83) | def __init__(self, instr_len: int, uuid: str = "minigrid_mission", **k...
method _get_observation_space (line 103) | def _get_observation_space(self) -> gym.Space:
method get_observation (line 111) | def get_observation(
FILE: allenact_plugins/minigrid_plugin/minigrid_tasks.py
class MiniGridTask (line 25) | class MiniGridTask(Task[CrossingEnv]):
method __init__ (line 50) | def __init__(
method action_space (line 72) | def action_space(self) -> gym.spaces.Discrete:
method render (line 75) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method _step (line 78) | def _step(self, action: int) -> RLStepResult:
method get_observations (line 95) | def get_observations(
method reached_terminal_state (line 102) | def reached_terminal_state(self) -> bool:
method class_action_names (line 106) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 109) | def close(self) -> None:
method metrics (line 112) | def metrics(self) -> Dict[str, Any]:
method graph_created (line 126) | def graph_created(self):
method graph (line 130) | def graph(self):
method graph (line 141) | def graph(self, graph: nx.DiGraph):
method possible_neighbor_offsets (line 145) | def possible_neighbor_offsets(cls) -> Tuple[Tuple[int, int, int], ...]:
method _add_from_to_edge (line 165) | def _add_from_to_edge(
method _add_node_to_graph (line 223) | def _add_node_to_graph(
method generate_graph (line 250) | def generate_graph(
method query_expert (line 294) | def query_expert(self, **kwargs) -> Tuple[int, bool]:
class AskForHelpSimpleCrossingTask (line 350) | class AskForHelpSimpleCrossingTask(MiniGridTask):
method __init__ (line 357) | def __init__(
method _step (line 371) | def _step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method metrics (line 378) | def metrics(self) -> Dict[str, Any]:
class MiniGridTaskSampler (line 387) | class MiniGridTaskSampler(TaskSampler):
method __init__ (line 388) | def __init__(
method length (line 469) | def length(self) -> Union[int, float]:
method total_unique (line 477) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 481) | def last_sampled_task(self) -> Optional[Task]:
method next_task (line 484) | def next_task(self, force_advance_scene: bool = False) -> Optional[Min...
method close (line 547) | def close(self) -> None:
method all_observation_spaces_equal (line 551) | def all_observation_spaces_equal(self) -> bool:
method reset (line 554) | def reset(self) -> None:
method set_seed (line 558) | def set_seed(self, seed: int) -> None:
FILE: allenact_plugins/navigation_plugin/objectnav/models.py
class CatObservations (line 23) | class CatObservations(nn.Module):
method __init__ (line 24) | def __init__(self, ordered_uuids: Sequence[str], dim: int):
method forward (line 31) | def forward(self, observations: ObservationType):
class ObjectNavActorCritic (line 39) | class ObjectNavActorCritic(VisualNavActorCritic):
method __init__ (line 55) | def __init__(
method is_blind (line 170) | def is_blind(self) -> bool:
method goal_visual_encoder_output_dims (line 176) | def goal_visual_encoder_output_dims(self):
method get_object_type_encoding (line 182) | def get_object_type_encoding(
method forward_encoder (line 191) | def forward_encoder(self, observations: ObservationType) -> torch.Tensor:
class ResnetTensorNavActorCritic (line 205) | class ResnetTensorNavActorCritic(VisualNavActorCritic):
method __init__ (line 206) | def __init__(
method is_blind (line 286) | def is_blind(self) -> bool:
method forward_encoder (line 291) | def forward_encoder(self, observations: ObservationType) -> torch.Floa...
class ResnetTensorGoalEncoder (line 295) | class ResnetTensorGoalEncoder(nn.Module):
method __init__ (line 296) | def __init__(
method is_blind (line 343) | def is_blind(self):
method output_dims (line 347) | def output_dims(self):
method get_object_type_encoding (line 357) | def get_object_type_encoding(
method compress_resnet (line 366) | def compress_resnet(self, observations):
method distribute_target (line 369) | def distribute_target(self, observations):
method adapt_input (line 375) | def adapt_input(self, observations):
method adapt_output (line 395) | def adapt_output(x, use_agent, nstep, nsampler, nagent):
method forward (line 400) | def forward(self, observations):
class ResnetDualTensorGoalEncoder (line 422) | class ResnetDualTensorGoalEncoder(nn.Module):
method __init__ (line 423) | def __init__(
method is_blind (line 492) | def is_blind(self):
method output_dims (line 496) | def output_dims(self):
method get_object_type_encoding (line 507) | def get_object_type_encoding(
method compress_rgb_resnet (line 516) | def compress_rgb_resnet(self, observations):
method compress_depth_resnet (line 519) | def compress_depth_resnet(self, observations):
method distribute_target (line 522) | def distribute_target(self, observations):
method adapt_input (line 528) | def adapt_input(self, observations):
method adapt_output (line 548) | def adapt_output(x, use_agent, nstep, nsampler, nagent):
method forward (line 553) | def forward(self, observations):
FILE: allenact_plugins/navigation_plugin/pointnav/models.py
class PointNavActorCritic (line 23) | class PointNavActorCritic(VisualNavActorCritic):
method __init__ (line 26) | def __init__(
method is_blind (line 115) | def is_blind(self):
method goal_visual_encoder_output_dims (line 119) | def goal_visual_encoder_output_dims(self):
method get_target_coordinates_encoding (line 125) | def get_target_coordinates_encoding(self, observations):
method forward_encoder (line 133) | def forward_encoder(self, observations: ObservationType) -> torch.Floa...
FILE: allenact_plugins/robothor_plugin/robothor_distributions.py
class TupleCategoricalDistr (line 8) | class TupleCategoricalDistr(Distr):
method __init__ (line 9) | def __init__(self, probs=None, logits=None, validate_args=None):
method log_prob (line 14) | def log_prob(self, actions: Tuple[torch.LongTensor, ...]) -> torch.Flo...
method entropy (line 18) | def entropy(self) -> torch.FloatTensor:
method sample (line 22) | def sample(self, sample_shape=torch.Size()) -> Tuple[torch.LongTensor,...
method mode (line 27) | def mode(self) -> Tuple[torch.LongTensor, ...]:
FILE: allenact_plugins/robothor_plugin/robothor_environment.py
class RoboThorEnvironment (line 18) | class RoboThorEnvironment:
method __init__ (line 31) | def __init__(self, all_metadata_available: bool = True, **kwargs):
method initialize_grid_dimensions (line 79) | def initialize_grid_dimensions(
method set_object_filter (line 99) | def set_object_filter(self, object_ids: List[str]):
method reset_object_filter (line 102) | def reset_object_filter(self):
method path_from_point_to_object_type (line 105) | def path_from_point_to_object_type(
method distance_from_point_to_object_type (line 127) | def distance_from_point_to_object_type(
method distance_to_object_type (line 145) | def distance_to_object_type(self, object_type: str, agent_id: int = 0)...
method path_from_point_to_point (line 189) | def path_from_point_to_point(
method distance_from_point_to_point (line 212) | def distance_from_point_to_point(
method distance_to_point (line 229) | def distance_to_point(self, target: Dict[str, float], agent_id: int = ...
method agent_state (line 271) | def agent_state(self, agent_id: int = 0) -> Dict:
method teleport (line 282) | def teleport(
method reset (line 311) | def reset(
method random_reachable_state (line 332) | def random_reachable_state(
method randomize_agent_location (line 357) | def randomize_agent_location(
method known_good_locations_list (line 395) | def known_good_locations_list(self):
method currently_reachable_points (line 402) | def currently_reachable_points(self) -> List[Dict[str, float]]:
method scene_name (line 412) | def scene_name(self) -> str:
method current_frame (line 417) | def current_frame(self) -> np.ndarray:
method current_depth (line 422) | def current_depth(self) -> np.ndarray:
method current_frames (line 427) | def current_frames(self) -> List[np.ndarray]:
method current_depths (line 435) | def current_depths(self) -> List[np.ndarray]:
method last_event (line 444) | def last_event(self) -> ai2thor.server.Event:
method last_action (line 449) | def last_action(self) -> str:
method last_action_success (line 454) | def last_action_success(self) -> bool:
method last_action_return (line 459) | def last_action_return(self) -> Any:
method step (line 467) | def step(
method stop (line 479) | def stop(self):
method all_objects (line 486) | def all_objects(self) -> List[Dict[str, Any]]:
method all_objects_with_properties (line 490) | def all_objects_with_properties(
method visible_objects (line 505) | def visible_objects(self) -> List[Dict[str, Any]]:
FILE: allenact_plugins/robothor_plugin/robothor_models.py
class TupleLinearActorCriticHead (line 21) | class TupleLinearActorCriticHead(LinearActorCriticHead):
method forward (line 22) | def forward(self, x):
class NavToPartnerActorCriticSimpleConvRNN (line 34) | class NavToPartnerActorCriticSimpleConvRNN(ActorCriticModel[TupleCategor...
method __init__ (line 37) | def __init__(
method output_size (line 73) | def output_size(self):
method is_blind (line 77) | def is_blind(self):
method num_recurrent_layers (line 81) | def num_recurrent_layers(self):
method recurrent_hidden_state_size (line 85) | def recurrent_hidden_state_size(self):
method num_agents (line 89) | def num_agents(self):
method _recurrent_memory_specification (line 92) | def _recurrent_memory_specification(self):
method forward (line 105) | def forward( # type:ignore
FILE: allenact_plugins/robothor_plugin/robothor_preprocessors.py
class BatchedFasterRCNN (line 14) | class BatchedFasterRCNN(torch.nn.Module):
method __init__ (line 32) | def __init__(self, thres=0.12, maxdets=3, res=7):
method detector_tensor (line 41) | def detector_tensor(self, boxes, classes, scores, aspect_ratio=1.0):
method forward (line 94) | def forward(self, imbatch):
class FasterRCNNPreProcessorRoboThor (line 155) | class FasterRCNNPreProcessorRoboThor(Preprocessor):
method __init__ (line 160) | def __init__(
method to (line 212) | def to(self, device: torch.device) -> "FasterRCNNPreProcessorRoboThor":
method process (line 217) | def process(self, obs: Dict[str, Any], *args: Any, **kwargs: Any) -> Any:
FILE: allenact_plugins/robothor_plugin/robothor_sensors.py
class RGBSensorRoboThor (line 22) | class RGBSensorRoboThor(RGBSensorThor):
method __init__ (line 29) | def __init__(self, *args: Any, **kwargs: Any):
class RGBSensorMultiRoboThor (line 36) | class RGBSensorMultiRoboThor(RGBSensor[RoboThorEnvironment, Task[RoboTho...
method __init__ (line 43) | def __init__(self, agent_count: int = 2, **kwargs):
method frame_from_env (line 49) | def frame_from_env(
method get_observation (line 54) | def get_observation(
class GPSCompassSensorRoboThor (line 67) | class GPSCompassSensorRoboThor(Sensor[RoboThorEnvironment, PointNavTask]):
method __init__ (line 68) | def __init__(self, uuid: str = "target_coordinates_ind", **kwargs: Any):
method _get_observation_space (line 73) | def _get_observation_space(self):
method _compute_pointgoal (line 82) | def _compute_pointgoal(
method quaternion_from_y_angle (line 98) | def quaternion_from_y_angle(angle: float) -> np.quaternion:
method quaternion_from_coeff (line 107) | def quaternion_from_coeff(coeffs: np.ndarray) -> np.quaternion:
method cartesian_to_polar (line 115) | def cartesian_to_polar(x, y):
method quaternion_rotate_vector (line 121) | def quaternion_rotate_vector(quat: np.quaternion, v: np.array) -> np.a...
method get_observation (line 133) | def get_observation(
class DepthSensorThor (line 154) | class DepthSensorThor(
method __init__ (line 160) | def __init__(
method frame_from_env (line 184) | def frame_from_env(
class DepthSensorRoboThor (line 193) | class DepthSensorRoboThor(DepthSensorThor):
method __init__ (line 195) | def __init__(self, *args: Any, **kwargs: Any):
FILE: allenact_plugins/robothor_plugin/robothor_task_samplers.py
class ObjectNavTaskSampler (line 22) | class ObjectNavTaskSampler(TaskSampler):
method __init__ (line 23) | def __init__(
method _create_environment (line 98) | def _create_environment(self) -> RoboThorEnvironment:
method length (line 103) | def length(self) -> Union[int, float]:
method total_unique (line 113) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 117) | def last_sampled_task(self) -> Optional[ObjectNavTask]:
method close (line 120) | def close(self) -> None:
method all_observation_spaces_equal (line 125) | def all_observation_spaces_equal(self) -> bool:
method sample_scene (line 135) | def sample_scene(self, force_advance_scene: bool):
method next_task (line 182) | def next_task(self, force_advance_scene: bool = False) -> Optional[Obj...
method reset (line 278) | def reset(self):
method set_seed (line 286) | def set_seed(self, seed: int):
class ObjectNavDatasetTaskSampler (line 292) | class ObjectNavDatasetTaskSampler(TaskSampler):
method __init__ (line 293) | def __init__(
method _create_environment (line 367) | def _create_environment(self) -> RoboThorEnvironment:
method load_dataset (line 372) | def load_dataset(scene: str, base_directory: str) -> List[Dict]:
method load_distance_cache_from_file (line 388) | def load_distance_cache_from_file(scene: str, base_directory: str) -> ...
method __len__ (line 403) | def __len__(self) -> Union[int, float]:
method total_unique (line 413) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 417) | def last_sampled_task(self) -> Optional[ObjectNavTask]:
method close (line 420) | def close(self) -> None:
method all_observation_spaces_equal (line 425) | def all_observation_spaces_equal(self) -> bool:
method length (line 436) | def length(self) -> Union[int, float]:
method next_task (line 445) | def next_task(self, force_advance_scene: bool = False) -> Optional[Obj...
method reset (line 524) | def reset(self):
method set_seed (line 529) | def set_seed(self, seed: int):
class PointNavTaskSampler (line 535) | class PointNavTaskSampler(TaskSampler):
method __init__ (line 536) | def __init__(
method _create_environment (line 583) | def _create_environment(self) -> RoboThorEnvironment:
method length (line 588) | def length(self) -> Union[int, float]:
method total_unique (line 599) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 607) | def last_sampled_task(self) -> Optional[PointNavTask]:
method close (line 610) | def close(self) -> None:
method all_observation_spaces_equal (line 615) | def all_observation_spaces_equal(self) -> bool:
method sample_scene (line 625) | def sample_scene(self, force_advance_scene: bool):
method next_task (line 672) | def next_task(self, force_advance_scene: bool = False) -> Optional[Poi...
method reset (line 739) | def reset(self):
method set_seed (line 751) | def set_seed(self, seed: int):
class PointNavDatasetTaskSampler (line 757) | class PointNavDatasetTaskSampler(TaskSampler):
method __init__ (line 758) | def __init__(
method _create_environment (line 813) | def _create_environment(self) -> RoboThorEnvironment:
method __len__ (line 818) | def __len__(self) -> Union[int, float]:
method total_unique (line 828) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 832) | def last_sampled_task(self) -> Optional[PointNavTask]:
method close (line 835) | def close(self) -> None:
method all_observation_spaces_equal (line 840) | def all_observation_spaces_equal(self) -> bool:
method next_task (line 850) | def next_task(self, force_advance_scene: bool = False) -> Optional[Poi...
method reset (line 917) | def reset(self):
method set_seed (line 922) | def set_seed(self, seed: int):
method length (line 928) | def length(self) -> Union[int, float]:
class NavToPartnerTaskSampler (line 939) | class NavToPartnerTaskSampler(TaskSampler):
method __init__ (line 940) | def __init__(
method _create_environment (line 981) | def _create_environment(self) -> RoboThorEnvironment:
method length (line 989) | def length(self) -> Union[int, float]:
method total_unique (line 1000) | def total_unique(self) -> Optional[Union[int, float]]:
method last_sampled_task (line 1004) | def last_sampled_task(self) -> Optional[NavToPartnerTask]:
method close (line 1007) | def close(self) -> None:
method all_observation_spaces_equal (line 1012) | def all_observation_spaces_equal(self) -> bool:
method sample_scene (line 1022) | def sample_scene(self, force_advance_scene: bool):
method next_task (line 1063) | def next_task(
method reset (line 1129) | def reset(self):
method set_seed (line 1136) | def set_seed(self, seed: int):
FILE: allenact_plugins/robothor_plugin/robothor_tasks.py
function spl_metric (line 24) | def spl_metric(
class PointNavTask (line 41) | class PointNavTask(Task[RoboThorEnvironment]):
method __init__ (line 44) | def __init__(
method action_space (line 76) | def action_space(self):
method reached_terminal_state (line 79) | def reached_terminal_state(self) -> bool:
method class_action_names (line 83) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 86) | def close(self) -> None:
method _step (line 89) | def _step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method render (line 117) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method _is_goal_in_range (line 124) | def _is_goal_in_range(self) -> Optional[bool]:
method shaping (line 140) | def shaping(self) -> float:
method judge (line 158) | def judge(self) -> float:
method dist_to_target (line 177) | def dist_to_target(self):
method metrics (line 180) | def metrics(self) -> Dict[str, Any]:
class ObjectNavTask (line 207) | class ObjectNavTask(Task[RoboThorEnvironment]):
method __init__ (line 210) | def __init__(
method action_space (line 252) | def action_space(self):
method reached_terminal_state (line 255) | def reached_terminal_state(self) -> bool:
method class_action_names (line 259) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 262) | def close(self) -> None:
method _step (line 265) | def _step(self, action: Union[int, Sequence[int]]) -> RLStepResult:
method render (line 301) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method _is_goal_in_range (line 315) | def _is_goal_in_range(self) -> bool:
method shaping (line 321) | def shaping(self) -> float:
method judge (line 359) | def judge(self) -> float:
method get_observations (line 376) | def get_observations(self, **kwargs) -> Any:
method metrics (line 389) | def metrics(self) -> Dict[str, Any]:
method query_expert (line 412) | def query_expert(self, end_action_only: bool = False, **kwargs) -> Tup...
class NavToPartnerTask (line 453) | class NavToPartnerTask(Task[RoboThorEnvironment]):
method __init__ (line 456) | def __init__(
method action_space (line 486) | def action_space(self):
method reached_terminal_state (line 494) | def reached_terminal_state(self) -> bool:
method class_action_names (line 500) | def class_action_names(cls, **kwargs) -> Tuple[str, ...]:
method close (line 503) | def close(self) -> None:
method _step (line 506) | def _step(self, action: Tuple[int, int]) -> RLStepResult:
method render (line 542) | def render(self, mode: str = "rgb", *args, **kwargs) -> np.ndarray:
method judge (line 549) | def judge(self) -> float:
method metrics (line 558) | def metrics(self) -> Dict[str, Any]:
FILE: allenact_plugins/robothor_plugin/robothor_viz.py
class ThorPositionTo2DFrameTranslator (line 23) | class ThorPositionTo2DFrameTranslator(object):
method __init__ (line 24) | def __init__(
method __call__ (line 34) | def __call__(self, position: Sequence[float]):
class ThorViz (line 50) | class ThorViz(TrajectoryViz):
method __init__ (line 51) | def __init__(
method init_top_down_render (line 96) | def init_top_down_render(self):
method iterate_scenes (line 106) | def iterate_scenes(
method cached_map_data_path (line 115) | def cached_map_data_path(self, roomname: str) -> str:
method get_translator (line 118) | def get_translator(self) -> Dict[str, Any]:
method cached_image_path (line 142) | def cached_image_path(self, roomname: str) -> str:
method make_top_down_views (line 147) | def make_top_down_views(self) -> Dict[str, np.ndarray]:
method crop_viz_image (line 158) | def crop_viz_image(self, viz_image: np.ndarray) -> np.ndarray:
method make_controller (line 168) | def make_controller(self):
method get_agent_map_data (line 181) | def get_agent_map_data(self):
method position_to_tuple (line 193) | def position_to_tuple(position: Dict[str, float]) -> Tuple[float, floa...
method add_lines_to_map (line 197) | def add_lines_to_map(
method add_line_to_map (line 226) | def add_line_to_map(
method add_agent_view_triangle (line 254) | def add_agent_view_triangle(
method visualize_agent_path (line 288) | def visualize_agent_path(
method dump_top_down_view (line 342) | def dump_top_down_view(self, room_name: str, image_path: str):
method make_fig (line 354) | def make_fig(self, episode: Any, episode_id: str) -> Figure:
class ThorMultiViz (line 382) | class ThorMultiViz(ThorViz):
method __init__ (line 383) | def __init__(
method make_fig (line 400) | def make_fig(self, episode: Any, episode_id: str) -> Figure:
FILE: allenact_plugins/robothor_plugin/scripts/make_objectnav_debug_dataset.py
function create_debug_dataset_from_train_dataset (line 11) | def create_debug_dataset_from_train_dataset(
FILE: allenact_plugins/setup.py
function parse_req_file (line 8) | def parse_req_file(fname, initial=None):
function get_version (line 45) | def get_version(fname):
function run_setup (line 60) | def run_setup():
FILE: datasets/.habitat_downloader_helper.py
function get_habitat_download_info (line 14) | def get_habitat_download_info(allow_create: bool = False):
FILE: projects/babyai_baselines/experiments/base.py
class BaseBabyAIExperimentConfig (line 32) | class BaseBabyAIExperimentConfig(ExperimentConfig, ABC):
method METRIC_ACCUMULATE_INTERVAL (line 55) | def METRIC_ACCUMULATE_INTERVAL(cls):
method get_sensors (line 59) | def get_sensors(cls) -> Sequence[Sensor]:
method rl_loss_default (line 85) | def rl_loss_default(cls, alg: str, steps: Optional[int] = None):
method _training_pipeline (line 113) | def _training_pipeline(
method machine_params (line 156) | def machine_params(
method create_model (line 181) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 192) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 195) | def train_task_sampler_args(
method valid_task_sampler_args (line 209) | def valid_task_sampler_args(
method test_task_sampler_args (line 219) | def test_task_sampler_args(
FILE: projects/babyai_baselines/experiments/go_to_local/a2c.py
class A2CBabyAIGoToLocalExperimentConfig (line 9) | class A2CBabyAIGoToLocalExperimentConfig(BaseBabyAIGoToLocalExperimentCo...
method tag (line 22) | def tag(cls):
method training_pipeline (line 26) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_local/base.py
class BaseBabyAIGoToLocalExperimentConfig (line 24) | class BaseBabyAIGoToLocalExperimentConfig(BaseBabyAIExperimentConfig, ABC):
method METRIC_ACCUMULATE_INTERVAL (line 47) | def METRIC_ACCUMULATE_INTERVAL(cls):
method _training_pipeline (line 51) | def _training_pipeline( # type:ignore
method create_model (line 100) | def create_model(cls, **kwargs) -> nn.Module:
method valid_task_sampler_args (line 114) | def valid_task_sampler_args(
FILE: projects/babyai_baselines/experiments/go_to_local/bc.py
class PPOBabyAIGoToLocalExperimentConfig (line 7) | class PPOBabyAIGoToLocalExperimentConfig(BaseBabyAIGoToLocalExperimentCo...
method tag (line 13) | def tag(cls):
method training_pipeline (line 17) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_local/bc_teacher_forcing.py
class BCTeacherForcingBabyAIGoToLocalExperimentConfig (line 9) | class BCTeacherForcingBabyAIGoToLocalExperimentConfig(
method METRIC_ACCUMULATE_INTERVAL (line 19) | def METRIC_ACCUMULATE_INTERVAL(cls):
method tag (line 23) | def tag(cls):
method training_pipeline (line 27) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_local/dagger.py
class DaggerBabyAIGoToLocalExperimentConfig (line 7) | class DaggerBabyAIGoToLocalExperimentConfig(BaseBabyAIGoToLocalExperimen...
method tag (line 16) | def tag(cls):
method training_pipeline (line 20) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_local/distributed_bc_offpolicy.py
class DistributedBCOffPolicyBabyAIGoToLocalExperimentConfig (line 25) | class DistributedBCOffPolicyBabyAIGoToLocalExperimentConfig(
method tag (line 31) | def tag(cls):
method machine_params (line 35) | def machine_params(
method expert_ce_loss_kwargs_generator (line 48) | def expert_ce_loss_kwargs_generator(
method training_pipeline (line 54) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_local/distributed_bc_teacher_forcing.py
class DistributedBCTeacherForcingBabyAIGoToLocalExperimentConfig (line 6) | class DistributedBCTeacherForcingBabyAIGoToLocalExperimentConfig(
method METRIC_ACCUMULATE_INTERVAL (line 16) | def METRIC_ACCUMULATE_INTERVAL(cls):
method tag (line 20) | def tag(cls):
method machine_params (line 24) | def machine_params(
FILE: projects/babyai_baselines/experiments/go_to_local/ppo.py
class PPOBabyAIGoToLocalExperimentConfig (line 9) | class PPOBabyAIGoToLocalExperimentConfig(BaseBabyAIGoToLocalExperimentCo...
method tag (line 22) | def tag(cls):
method training_pipeline (line 26) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_obj/a2c.py
class A2CBabyAIGoToObjExperimentConfig (line 7) | class A2CBabyAIGoToObjExperimentConfig(BaseBabyAIGoToObjExperimentConfig):
method tag (line 13) | def tag(cls):
method training_pipeline (line 17) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_obj/base.py
class BaseBabyAIGoToObjExperimentConfig (line 22) | class BaseBabyAIGoToObjExperimentConfig(BaseBabyAIExperimentConfig, ABC):
method METRIC_ACCUMULATE_INTERVAL (line 44) | def METRIC_ACCUMULATE_INTERVAL(cls):
method _training_pipeline (line 48) | def _training_pipeline( # type:ignore
method create_model (line 97) | def create_model(cls, **kwargs) -> nn.Module:
FILE: projects/babyai_baselines/experiments/go_to_obj/bc.py
class PPOBabyAIGoToObjExperimentConfig (line 7) | class PPOBabyAIGoToObjExperimentConfig(BaseBabyAIGoToObjExperimentConfig):
method tag (line 13) | def tag(cls):
method training_pipeline (line 17) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_obj/bc_teacher_forcing.py
class PPOBabyAIGoToObjExperimentConfig (line 7) | class PPOBabyAIGoToObjExperimentConfig(BaseBabyAIGoToObjExperimentConfig):
method tag (line 13) | def tag(cls):
method training_pipeline (line 17) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_obj/dagger.py
class DaggerBabyAIGoToObjExperimentConfig (line 7) | class DaggerBabyAIGoToObjExperimentConfig(BaseBabyAIGoToObjExperimentCon...
method tag (line 16) | def tag(cls):
method training_pipeline (line 20) | def training_pipeline(cls, **kwargs):
FILE: projects/babyai_baselines/experiments/go_to_obj/ppo.py
class PPOBabyAIGoToObjExperimentConfig (line 7) | class PPOBabyAIGoToObjExperimentConfig(BaseBabyAIGoToObjExperimentConfig):
method tag (line 11) | def tag(cls):
method training_pipeline (line 15) | def training_pipeline(cls, **kwargs):
FILE: projects/gym_baselines/experiments/gym_base.py
class GymBaseConfig (line 8) | class GymBaseConfig(ExperimentConfig, ABC):
method _get_sampler_args (line 12) | def _get_sampler_args(
method train_task_sampler_args (line 17) | def train_task_sampler_args(
method valid_task_sampler_args (line 29) | def valid_task_sampler_args(
method test_task_sampler_args (line 41) | def test_task_sampler_args(
FILE: projects/gym_baselines/experiments/gym_humanoid_base.py
class GymHumanoidBaseConfig (line 9) | class GymHumanoidBaseConfig(GymBaseConfig, ABC):
method machine_params (line 11) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
FILE: projects/gym_baselines/experiments/gym_humanoid_ddppo.py
class GymHumanoidPPOConfig (line 19) | class GymHumanoidPPOConfig(GymHumanoidBaseConfig, ABC):
method training_pipeline (line 21) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
FILE: projects/gym_baselines/experiments/gym_mujoco_base.py
class GymMoJoCoBaseConfig (line 9) | class GymMoJoCoBaseConfig(GymBaseConfig, ABC):
method machine_params (line 11) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
FILE: projects/gym_baselines/experiments/gym_mujoco_ddppo.py
class GymMuJoCoPPOConfig (line 19) | class GymMuJoCoPPOConfig(GymMoJoCoBaseConfig, ABC):
method training_pipeline (line 21) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_ant_ddppo.py
class GymMuJoCoAntConfig (line 16) | class GymMuJoCoAntConfig(GymMuJoCoPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 42) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 45) | def _get_sampler_args(
method tag (line 83) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_halfcheetah_ddppo.py
class GymMuJoCoHalfCheetahConfig (line 16) | class GymMuJoCoHalfCheetahConfig(GymMuJoCoPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 42) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 45) | def _get_sampler_args(
method tag (line 83) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_hopper_ddppo.py
class GymMuJoCoHopperConfig (line 16) | class GymMuJoCoHopperConfig(GymMuJoCoPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 42) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 45) | def _get_sampler_args(
method tag (line 83) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_humanoid_ddppo.py
class GymMuJoCoHumanoidConfig (line 16) | class GymMuJoCoHumanoidConfig(GymHumanoidPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 44) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 47) | def _get_sampler_args(
method tag (line 85) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_inverteddoublependulum_ddppo.py
class GymMuJoInvertedDoublePendulumConfig (line 16) | class GymMuJoInvertedDoublePendulumConfig(GymMuJoCoPPOConfig):
method create_model (line 25) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 44) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 47) | def _get_sampler_args(
method tag (line 85) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_invertedpendulum_ddppo.py
class GymMuJoCoInvertedPendulumConfig (line 16) | class GymMuJoCoInvertedPendulumConfig(GymMuJoCoPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 42) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 45) | def _get_sampler_args(
method tag (line 83) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_reacher_ddppo.py
class GymMuJoCoReacherConfig (line 16) | class GymMuJoCoReacherConfig(GymMuJoCoPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 42) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 45) | def _get_sampler_args(
method tag (line 83) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_swimmer_ddppo.py
class GymMuJoCoSwimmerConfig (line 16) | class GymMuJoCoSwimmerConfig(GymMuJoCoPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 42) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 45) | def _get_sampler_args(
method tag (line 83) | def tag(cls) -> str:
FILE: projects/gym_baselines/experiments/mujoco/gym_mujoco_walker2d_ddppo.py
class GymMuJoCoWalkerConfig (line 16) | class GymMuJoCoWalkerConfig(GymMuJoCoPPOConfig):
method create_model (line 23) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 42) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _get_sampler_args (line 45) | def _get_sampler_args(
method tag (line 83) | def tag(cls) -> str:
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/armpointnav_base.py
class ArmPointNavBaseConfig (line 10) | class ArmPointNavBaseConfig(ExperimentConfig, ABC):
method __init__ (line 26) | def __init__(self):
method preprocessors (line 37) | def preprocessors(cls) -> Sequence[Union[Preprocessor, Builder[Preproc...
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/armpointnav_mixin_ddppo.py
class ArmPointNavMixInPPOConfig (line 17) | class ArmPointNavMixInPPOConfig(ArmPointNavBaseConfig):
method training_pipeline (line 18) | def training_pipeline(self, **kwargs):
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/armpointnav_mixin_simplegru.py
class ArmPointNavMixInSimpleGRUConfig (line 17) | class ArmPointNavMixInSimpleGRUConfig(ArmPointNavBaseConfig):
method preprocessors (line 21) | def preprocessors(cls) -> Sequence[Union[Preprocessor, Builder[Preproc...
method create_model (line 26) | def create_model(cls, **kwargs) -> nn.Module:
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/armpointnav_thor_base.py
class ArmPointNavThorBaseConfig (line 28) | class ArmPointNavThorBaseConfig(ArmPointNavBaseConfig, ABC):
method __init__ (line 57) | def __init__(self):
method machine_params (line 68) | def machine_params(self, mode="train", **kwargs):
method make_sampler_fn (line 119) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _partition_inds (line 136) | def _partition_inds(n: int, num_parts: int):
method _get_sampler_args_for_scene_split (line 141) | def _get_sampler_args_for_scene_split(
method train_task_sampler_args (line 178) | def train_task_sampler_args(
method valid_task_sampler_args (line 203) | def valid_task_sampler_args(
method test_task_sampler_args (line 229) | def test_task_sampler_args(
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/ithor/armpointnav_depth.py
class ArmPointNavDepth (line 22) | class ArmPointNavDepth(
method __init__ (line 45) | def __init__(self):
method tag (line 57) | def tag(cls):
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/ithor/armpointnav_disjoint_depth.py
class ArmPointNavDisjointDepth (line 16) | class ArmPointNavDisjointDepth(ArmPointNavDepth):
method __init__ (line 22) | def __init__(self):
method create_model (line 34) | def create_model(cls, **kwargs) -> nn.Module:
method tag (line 44) | def tag(cls):
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/ithor/armpointnav_ithor_base.py
class ArmPointNaviThorBaseConfig (line 12) | class ArmPointNaviThorBaseConfig(ArmPointNavThorBaseConfig, ABC):
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/ithor/armpointnav_no_vision.py
class ArmPointNavNoVision (line 22) | class ArmPointNavNoVision(
method __init__ (line 45) | def __init__(self):
method tag (line 57) | def tag(cls):
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/ithor/armpointnav_rgb.py
class ArmPointNavRGB (line 22) | class ArmPointNavRGB(
method __init__ (line 45) | def __init__(self):
method tag (line 57) | def tag(cls):
FILE: projects/manipulathor_baselines/armpointnav_baselines/experiments/ithor/armpointnav_rgbdepth.py
class ArmPointNavRGBDepth (line 23) | class ArmPointNavRGBDepth(
method __init__ (line 52) | def __init__(self):
method tag (line 64) | def tag(cls):
FILE: projects/manipulathor_baselines/armpointnav_baselines/models/arm_pointnav_models.py
class ArmPointNavBaselineActorCritic (line 28) | class ArmPointNavBaselineActorCritic(ActorCriticModel[CategoricalDistr]):
method __init__ (line 41) | def __init__(
method recurrent_hidden_state_size (line 95) | def recurrent_hidden_state_size(self) -> int:
method num_recurrent_layers (line 100) | def num_recurrent_layers(self) -> int:
method _recurrent_memory_specification (line 104) | def _recurrent_memory_specification(self):
method get_relative_distance_embedding (line 116) | def get_relative_distance_embedding(
method forward (line 122) | def forward( # type:ignore
FILE: projects/manipulathor_baselines/armpointnav_baselines/models/base_models.py
class LinearActorHeadNoCategory (line 5) | class LinearActorHeadNoCategory(nn.Module):
method __init__ (line 6) | def __init__(self, num_inputs: int, num_outputs: int):
method forward (line 13) | def forward(self, x: torch.FloatTensor): # type: ignore
FILE: projects/manipulathor_baselines/armpointnav_baselines/models/disjoint_arm_pointnav_models.py
class DisjointArmPointNavBaselineActorCritic (line 30) | class DisjointArmPointNavBaselineActorCritic(ActorCriticModel[Categorica...
method __init__ (line 46) | def __init__(
method recurrent_hidden_state_size (line 104) | def recurrent_hidden_state_size(self) -> int:
method num_recurrent_layers (line 109) | def num_recurrent_layers(self) -> int:
method _recurrent_memory_specification (line 113) | def _recurrent_memory_specification(self):
method forward (line 125) | def forward( # type:ignore
FILE: projects/manipulathor_baselines/armpointnav_baselines/models/manipulathor_net_utils.py
function upshuffle (line 7) | def upshuffle(
function upshufflenorelu (line 23) | def upshufflenorelu(
function combine_block_w_bn (line 38) | def combine_block_w_bn(in_planes, out_planes):
function conv2d_block (line 46) | def conv2d_block(in_planes, out_planes, kernel_size, stride=1, padding=1):
function combine_block_w_do (line 56) | def combine_block_w_do(in_planes, out_planes, dropout=0.0):
function combine_block_no_do (line 64) | def combine_block_no_do(in_planes, out_planes):
function linear_block (line 71) | def linear_block(in_features, out_features, dropout=0.0):
function linear_block_norelu (line 79) | def linear_block_norelu(in_features, out_features):
function input_embedding_net (line 85) | def input_embedding_net(list_of_feature_sizes, dropout=0.0):
function _upsample_add (line 96) | def _upsample_add(x, y):
function replace_all_relu_w_leakyrelu (line 101) | def replace_all_relu_w_leakyrelu(model):
function replace_all_leakyrelu_w_relu (line 114) | def replace_all_leakyrelu_w_relu(model):
function replace_all_bn_w_groupnorm (line 125) | def replace_all_bn_w_groupnorm(model):
function flat_temporal (line 141) | def flat_temporal(tensor, batch_size, sequence_length):
function unflat_temporal (line 148) | def unflat_temporal(tensor, batch_size, sequence_length):
FILE: projects/objectnav_baselines/experiments/clip/mixins.py
class LookDownFirstResnetTensorNavActorCritic (line 27) | class LookDownFirstResnetTensorNavActorCritic(ResnetTensorNavActorCritic):
method __init__ (line 28) | def __init__(self, look_down_action_index: int, **kwargs):
method forward (line 37) | def forward( # type:ignore
class ClipResNetPreprocessGRUActorCriticMixin (line 61) | class ClipResNetPreprocessGRUActorCriticMixin:
method preprocessors (line 68) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 114) | def create_model(
FILE: projects/objectnav_baselines/experiments/habitat/clip/objectnav_habitat_rgb_clipresnet50gru_ddppo.py
class ObjectNavHabitatRGBClipResNet50GRUDDPPOExperimentConfig (line 22) | class ObjectNavHabitatRGBClipResNet50GRUDDPPOExperimentConfig(
method __init__ (line 29) | def __init__(self, lr: float, **kwargs):
method SENSORS (line 42) | def SENSORS(self):
method training_pipeline (line 54) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 62) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 65) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 73) | def tag(self):
FILE: projects/objectnav_baselines/experiments/habitat/clip/objectnav_habitat_rgb_clipresnet50gru_ddppo_increasingrollouts.py
class ObjectNavHabitatRGBClipResNet50GRUDDPPOIncreasingLengthExpConfig (line 18) | class ObjectNavHabitatRGBClipResNet50GRUDDPPOIncreasingLengthExpConfig(
method __init__ (line 21) | def __init__(self, lr=1e-4, **kwargs):
method training_pipeline (line 25) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method tag (line 101) | def tag(self):
FILE: projects/objectnav_baselines/experiments/habitat/objectnav_habitat_base.py
function create_objectnav_config (line 39) | def create_objectnav_config(
class ObjectNavHabitatBaseConfig (line 111) | class ObjectNavHabitatBaseConfig(ObjectNavBaseConfig, ABC):
method __init__ (line 145) | def __init__(
method _create_config (line 193) | def _create_config(
method DEFAULT_OBJECT_CATEGORIES_TO_IND (line 221) | def DEFAULT_OBJECT_CATEGORIES_TO_IND(self):
method TASK_DATA_DIR_TEMPLATE (line 259) | def TASK_DATA_DIR_TEMPLATE(self):
method BASE_CONFIG_YAML_PATH (line 265) | def BASE_CONFIG_YAML_PATH(self):
method TRAIN_CONFIG (line 271) | def TRAIN_CONFIG(self):
method VALID_CONFIG (line 281) | def VALID_CONFIG(self):
method TEST_CONFIG (line 292) | def TEST_CONFIG(self):
method TRAIN_CONFIGS_PER_PROCESS (line 302) | def TRAIN_CONFIGS_PER_PROCESS(self):
method TEST_CONFIG_PER_PROCESS (line 363) | def TEST_CONFIG_PER_PROCESS(self):
method train_scenes_path (line 366) | def train_scenes_path(self):
method valid_scenes_path (line 369) | def valid_scenes_path(self):
method test_scenes_path (line 372) | def test_scenes_path(self):
method tag (line 377) | def tag(self):
method preprocessors (line 387) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method machine_params (line 390) | def machine_params(self, mode="train", **kwargs):
method make_sampler_fn (line 429) | def make_sampler_fn(self, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 437) | def train_task_sampler_args(
method valid_task_sampler_args (line 453) | def valid_task_sampler_args(
method test_task_sampler_args (line 474) | def test_task_sampler_args(
FILE: projects/objectnav_baselines/experiments/ithor/objectnav_ithor_base.py
class ObjectNaviThorBaseConfig (line 11) | class ObjectNaviThorBaseConfig(ObjectNavThorBaseConfig, ABC):
FILE: projects/objectnav_baselines/experiments/ithor/objectnav_ithor_depth_resnet18gru_ddppo.py
class ObjectNaviThorDepthPPOExperimentConfig (line 18) | class ObjectNaviThorDepthPPOExperimentConfig(ObjectNaviThorBaseConfig):
method __init__ (line 34) | def __init__(self, **kwargs):
method training_pipeline (line 44) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 51) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 54) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 59) | def tag(self):
FILE: projects/objectnav_baselines/experiments/ithor/objectnav_ithor_rgb_resnet18gru_ddppo.py
class ObjectNaviThorRGBPPOExperimentConfig (line 20) | class ObjectNaviThorRGBPPOExperimentConfig(ObjectNaviThorBaseConfig):
method __init__ (line 36) | def __init__(self, **kwargs):
method training_pipeline (line 46) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 53) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 56) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 62) | def tag(cls):
FILE: projects/objectnav_baselines/experiments/ithor/objectnav_ithor_rgbd_resnet18gru_ddppo.py
class ObjectNaviThorRGBDPPOExperimentConfig (line 21) | class ObjectNaviThorRGBDPPOExperimentConfig(ObjectNaviThorBaseConfig):
method __init__ (line 43) | def __init__(self, **kwargs):
method training_pipeline (line 53) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 60) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 63) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 68) | def tag(self):
FILE: projects/objectnav_baselines/experiments/objectnav_base.py
class ObjectNavBaseConfig (line 10) | class ObjectNavBaseConfig(ExperimentConfig, ABC):
method __init__ (line 27) | def __init__(self):
method preprocessors (line 35) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
FILE: projects/objectnav_baselines/experiments/objectnav_thor_base.py
class ObjectNavThorBaseConfig (line 45) | class ObjectNavThorBaseConfig(ObjectNavBaseConfig, ABC):
method __init__ (line 66) | def __init__(
method env_args (line 98) | def env_args(self):
method machine_params (line 124) | def machine_params(self, mode="train", **kwargs):
method make_sampler_fn (line 184) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _partition_inds (line 188) | def _partition_inds(n: int, num_parts: int):
method _get_sampler_args_for_scene_split (line 193) | def _get_sampler_args_for_scene_split(
method train_task_sampler_args (line 276) | def train_task_sampler_args(
method valid_task_sampler_args (line 299) | def valid_task_sampler_args(
method test_task_sampler_args (line 321) | def test_task_sampler_args(
FILE: projects/objectnav_baselines/experiments/robothor/beta/objectnav_robothor_rgb_resnetgru_ddppo_and_gbc.py
class ObjectNavRoboThorResNet18GRURGBPPOExperimentConfig (line 28) | class ObjectNavRoboThorResNet18GRURGBPPOExperimentConfig(ObjectNavRoboTh...
method __init__ (line 47) | def __init__(self, **kwargs):
method preprocessors (line 57) | def preprocessors(self):
method create_model (line 60) | def create_model(self, **kwargs):
method training_pipeline (line 65) | def training_pipeline(self, **kwargs):
method tag (line 114) | def tag(self):
FILE: projects/objectnav_baselines/experiments/robothor/beta/objectnav_robothor_rgb_unfrozenresnet18gru_vdr_ddppo.py
function compute_inv_dyn_action_logits (line 43) | def compute_inv_dyn_action_logits(
class LastActionSuccessSensor (line 54) | class LastActionSuccessSensor(
method __init__ (line 60) | def __init__(self, uuid: str = "last_action_success", **kwargs: Any):
method get_observation (line 65) | def get_observation(
class VisibleObjectTypesSensor (line 75) | class VisibleObjectTypesSensor(
method __init__ (line 81) | def __init__(self, uuid: str = "visible_objects", **kwargs: Any):
method get_observation (line 93) | def get_observation(
class ObjectNavRoboThorVdrTmpRGBExperimentConfig (line 107) | class ObjectNavRoboThorVdrTmpRGBExperimentConfig(ObjectNavRoboThorBaseCo...
method __init__ (line 122) | def __init__(self, **kwargs):
method training_pipeline (line 134) | def training_pipeline(self, **kwargs):
method create_model (line 233) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 242) | def tag(self):
FILE: projects/objectnav_baselines/experiments/robothor/clip/objectnav_robothor_rgb_clipresnet50gru_ddppo.py
class ObjectNavRoboThorClipRGBPPOExperimentConfig (line 21) | class ObjectNavRoboThorClipRGBPPOExperimentConfig(ObjectNavRoboThorBaseC...
method __init__ (line 41) | def __init__(self, add_prev_actions: bool = False, **kwargs):
method training_pipeline (line 52) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 59) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 62) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 70) | def tag(cls):
FILE: projects/objectnav_baselines/experiments/robothor/clip/objectnav_robothor_rgb_clipresnet50x16gru_ddppo.py
class ObjectNavRoboThorRGBPPOExperimentConfig (line 21) | class ObjectNavRoboThorRGBPPOExperimentConfig(ObjectNavRoboThorBaseConfig):
method __init__ (line 41) | def __init__(self, add_prev_actions: bool = False, **kwargs):
method training_pipeline (line 52) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 59) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 62) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 70) | def tag(cls):
FILE: projects/objectnav_baselines/experiments/robothor/objectnav_robothor_base.py
class ObjectNavRoboThorBaseConfig (line 13) | class ObjectNavRoboThorBaseConfig(ObjectNavThorBaseConfig, ABC):
method train_task_sampler_args (line 46) | def train_task_sampler_args(
FILE: projects/objectnav_baselines/experiments/robothor/objectnav_robothor_depth_resnet18gru_ddppo.py
class ObjectNavRoboThorRGBPPOExperimentConfig (line 18) | class ObjectNavRoboThorRGBPPOExperimentConfig(ObjectNavRoboThorBaseConfig):
method __init__ (line 34) | def __init__(self, **kwargs):
method training_pipeline (line 44) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 51) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 54) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 59) | def tag(self):
FILE: projects/objectnav_baselines/experiments/robothor/objectnav_robothor_rgb_resnet18gru_dagger.py
class ObjectNavRoboThorRGBDAggerExperimentConfig (line 22) | class ObjectNavRoboThorRGBDAggerExperimentConfig(ObjectNavRoboThorBaseCo...
method __init__ (line 41) | def __init__(self, **kwargs):
method training_pipeline (line 53) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 58) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 61) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 67) | def tag(cls):
FILE: projects/objectnav_baselines/experiments/robothor/objectnav_robothor_rgb_resnet18gru_ddppo.py
class ObjectNavRoboThorRGBPPOExperimentConfig (line 20) | class ObjectNavRoboThorRGBPPOExperimentConfig(ObjectNavRoboThorBaseConfig):
method __init__ (line 36) | def __init__(self, **kwargs):
method training_pipeline (line 46) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 53) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 56) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 62) | def tag(cls):
FILE: projects/objectnav_baselines/experiments/robothor/objectnav_robothor_rgb_resnet50gru_ddppo.py
class ObjectNavRoboThorRGBPPOExperimentConfig (line 20) | class ObjectNavRoboThorRGBPPOExperimentConfig(ObjectNavRoboThorBaseConfig):
method __init__ (line 36) | def __init__(self, **kwargs):
method training_pipeline (line 46) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 53) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 56) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 61) | def tag(self):
FILE: projects/objectnav_baselines/experiments/robothor/objectnav_robothor_rgb_unfrozenresnet18gru_ddppo.py
class ObjectNavRoboThorRGBPPOExperimentConfig (line 17) | class ObjectNavRoboThorRGBPPOExperimentConfig(ObjectNavRoboThorBaseConfig):
method __init__ (line 33) | def __init__(self, **kwargs):
method training_pipeline (line 45) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 52) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 55) | def tag(self):
FILE: projects/objectnav_baselines/experiments/robothor/objectnav_robothor_rgbd_resnet18gru_ddppo.py
class ObjectNavRoboThorRGBPPOExperimentConfig (line 21) | class ObjectNavRoboThorRGBPPOExperimentConfig(ObjectNavRoboThorBaseConfig):
method __init__ (line 43) | def __init__(self, **kwargs):
method training_pipeline (line 53) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 60) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 63) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 68) | def tag(self):
FILE: projects/objectnav_baselines/mixins.py
class ResNetPreprocessGRUActorCriticMixin (line 51) | class ResNetPreprocessGRUActorCriticMixin:
method preprocessors (line 57) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 110) | def create_model(self, **kwargs) -> nn.Module:
class ObjectNavUnfrozenResNetWithGRUActorCriticMixin (line 132) | class ObjectNavUnfrozenResNetWithGRUActorCriticMixin:
method create_model (line 140) | def create_model(self, **kwargs) -> nn.Module:
class ObjectNavDAggerMixin (line 173) | class ObjectNavDAggerMixin:
method training_pipeline (line 175) | def training_pipeline(
function update_with_auxiliary_losses (line 236) | def update_with_auxiliary_losses(
class ObjectNavPPOMixin (line 332) | class ObjectNavPPOMixin:
method training_pipeline (line 334) | def training_pipeline(
FILE: projects/pointnav_baselines/experiments/habitat/clip/pointnav_habitat_rgb_clipresnet50gru_ddppo.py
class PointNavHabitatRGBClipResNet50GRUDDPPOExperimentConfig (line 21) | class PointNavHabitatRGBClipResNet50GRUDDPPOExperimentConfig(PointNavHab...
method __init__ (line 38) | def __init__(self, add_prev_actions: bool = False, **kwargs):
method training_pipeline (line 49) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method preprocessors (line 57) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method create_model (line 60) | def create_model(self, **kwargs) -> nn.Module:
method tag (line 68) | def tag(cls):
FILE: projects/pointnav_baselines/experiments/habitat/pointnav_habitat_base.py
function create_pointnav_config (line 34) | def create_pointnav_config(
class PointNavHabitatBaseConfig (line 99) | class PointNavHabitatBaseConfig(PointNavBaseConfig, ABC):
method __init__ (line 141) | def __init__(
method train_scenes_path (line 236) | def train_scenes_path(self):
method valid_scenes_path (line 239) | def valid_scenes_path(self):
method test_scenes_path (line 242) | def test_scenes_path(self):
method tag (line 248) | def tag(cls):
method preprocessors (line 251) | def preprocessors(self) -> Sequence[Union[Preprocessor, Builder[Prepro...
method machine_params (line 254) | def machine_params(self, mode="train", **kwargs):
method make_sampler_fn (line 294) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 299) | def train_task_sampler_args(
method valid_task_sampler_args (line 316) | def valid_task_sampler_args(
method test_task_sampler_args (line 336) | def test_task_sampler_args(
FILE: projects/pointnav_baselines/experiments/habitat/pointnav_habitat_depth_simpleconvgru_ddppo.py
class PointNavHabitatDepthDeterministiSimpleConvGRUDDPPOExperimentConfig (line 15) | class PointNavHabitatDepthDeterministiSimpleConvGRUDDPPOExperimentConfig(
method __init__ (line 30) | def __init__(self):
method training_pipeline (line 42) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 50) | def create_model(self, **kwargs):
method tag (line 53) | def tag(self):
FILE: projects/pointnav_baselines/experiments/habitat/pointnav_habitat_rgb_simpleconvgru_ddppo.py
class PointNavHabitatDepthDeterministiSimpleConvGRUDDPPOExperimentConfig (line 15) | class PointNavHabitatDepthDeterministiSimpleConvGRUDDPPOExperimentConfig(
method __init__ (line 30) | def __init__(self):
method training_pipeline (line 42) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 50) | def create_model(self, **kwargs):
method tag (line 54) | def tag(cls):
FILE: projects/pointnav_baselines/experiments/habitat/pointnav_habitat_rgbd_simpleconvgru_ddppo.py
class PointNavHabitatDepthDeterministiSimpleConvGRUDDPPOExperimentConfig (line 16) | class PointNavHabitatDepthDeterministiSimpleConvGRUDDPPOExperimentConfig(
method __init__ (line 36) | def __init__(self):
method training_pipeline (line 48) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 56) | def create_model(self, **kwargs):
method tag (line 59) | def tag(self):
FILE: projects/pointnav_baselines/experiments/ithor/pointnav_ithor_base.py
class PointNaviThorBaseConfig (line 9) | class PointNaviThorBaseConfig(PointNavThorBaseConfig, ABC):
FILE: projects/pointnav_baselines/experiments/ithor/pointnav_ithor_depth_simpleconvgru_ddppo.py
class PointNaviThorDepthPPOExperimentConfig (line 15) | class PointNaviThorDepthPPOExperimentConfig(PointNaviThorBaseConfig):
method __init__ (line 29) | def __init__(self):
method training_pipeline (line 41) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 49) | def create_model(self, **kwargs):
method tag (line 52) | def tag(self):
FILE: projects/pointnav_baselines/experiments/ithor/pointnav_ithor_rgb_simpleconvgru_ddppo.py
class PointNaviThorRGBPPOExperimentConfig (line 13) | class PointNaviThorRGBPPOExperimentConfig(PointNaviThorBaseConfig):
method __init__ (line 26) | def __init__(self):
method training_pipeline (line 38) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 46) | def create_model(self, **kwargs):
method tag (line 49) | def tag(self):
FILE: projects/pointnav_baselines/experiments/ithor/pointnav_ithor_rgbd_simpleconvgru_ddppo.py
class PointNaviThorRGBDPPOExperimentConfig (line 14) | class PointNaviThorRGBDPPOExperimentConfig(PointNaviThorBaseConfig):
method __init__ (line 34) | def __init__(self):
method training_pipeline (line 46) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 54) | def create_model(self, **kwargs):
method tag (line 57) | def tag(self):
FILE: projects/pointnav_baselines/experiments/pointnav_base.py
class PointNavBaseConfig (line 8) | class PointNavBaseConfig(ExperimentConfig, ABC):
method __init__ (line 24) | def __init__(self):
FILE: projects/pointnav_baselines/experiments/pointnav_thor_base.py
class PointNavThorBaseConfig (line 37) | class PointNavThorBaseConfig(PointNavBaseConfig, ABC):
method __init__ (line 52) | def __init__(self):
method preprocessors (line 67) | def preprocessors(self):
method machine_params (line 70) | def machine_params(self, mode="train", **kwargs):
method make_sampler_fn (line 117) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _partition_inds (line 121) | def _partition_inds(n: int, num_parts: int):
method _get_sampler_args_for_scene_split (line 126) | def _get_sampler_args_for_scene_split(
method train_task_sampler_args (line 195) | def train_task_sampler_args(
method valid_task_sampler_args (line 216) | def valid_task_sampler_args(
method test_task_sampler_args (line 237) | def test_task_sampler_args(
FILE: projects/pointnav_baselines/experiments/robothor/pointnav_robothor_base.py
class PointNavRoboThorBaseConfig (line 9) | class PointNavRoboThorBaseConfig(PointNavThorBaseConfig, ABC):
FILE: projects/pointnav_baselines/experiments/robothor/pointnav_robothor_depth_simpleconvgru_ddppo.py
class PointNavRoboThorRGBPPOExperimentConfig (line 17) | class PointNavRoboThorRGBPPOExperimentConfig(
method __init__ (line 33) | def __init__(self):
method training_pipeline (line 45) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 53) | def create_model(self, **kwargs):
method tag (line 56) | def tag(self):
FILE: projects/pointnav_baselines/experiments/robothor/pointnav_robothor_rgb_simpleconvgru_ddppo.py
class PointNavRoboThorRGBPPOExperimentConfig (line 13) | class PointNavRoboThorRGBPPOExperimentConfig(
method __init__ (line 29) | def __init__(self):
method training_pipeline (line 41) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 49) | def create_model(self, **kwargs):
method tag (line 52) | def tag(self):
FILE: projects/pointnav_baselines/experiments/robothor/pointnav_robothor_rgbd_simpleconvgru_ddppo.py
class PointNavRoboThorRGBPPOExperimentConfig (line 15) | class PointNavRoboThorRGBPPOExperimentConfig(
method __init__ (line 37) | def __init__(self):
method training_pipeline (line 49) | def training_pipeline(self, **kwargs) -> TrainingPipeline:
method create_model (line 57) | def create_model(self, **kwargs):
method tag (line 60) | def tag(self):
FILE: projects/pointnav_baselines/mixins.py
class TargetCoordinatesSensorHabitat (line 28) | class TargetCoordinatesSensorHabitat: #type:ignore
class PointNavUnfrozenResNetWithGRUActorCriticMixin (line 38) | class PointNavUnfrozenResNetWithGRUActorCriticMixin:
method create_model (line 46) | def create_model(self, **kwargs) -> nn.Module:
class PointNavPPOMixin (line 90) | class PointNavPPOMixin:
method training_pipeline (line 92) | def training_pipeline(
FILE: projects/tutorials/distributed_objectnav_tutorial.py
class DistributedObjectNavRoboThorRGBPPOExperimentConfig (line 75) | class DistributedObjectNavRoboThorRGBPPOExperimentConfig(BaseConfig):
method tag (line 76) | def tag(self) -> str:
method env_args (line 95) | def env_args(self):
method __init__ (line 107) | def __init__(
method machine_params (line 138) | def machine_params(self, mode="train", **kwargs):
method lr_scheduler (line 199) | def lr_scheduler(small_batch_steps, transition_steps, ppo_steps, lr_sc...
method training_pipeline (line 239) | def training_pipeline(self, **kwargs):
FILE: projects/tutorials/gym_mujoco_tutorial.py
class HandManipulateTutorialExperimentConfig (line 71) | class HandManipulateTutorialExperimentConfig(ExperimentConfig):
method tag (line 73) | def tag(cls) -> str:
method create_model (line 100) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 131) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 141) | def train_task_sampler_args(
method valid_task_sampler_args (line 153) | def valid_task_sampler_args(
method test_task_sampler_args (line 165) | def test_task_sampler_args(
method _get_sampler_args (line 182) | def _get_sampler_args(
method machine_params (line 233) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
method training_pipeline (line 263) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
FILE: projects/tutorials/gym_tutorial.py
class GymTutorialExperimentConfig (line 73) | class GymTutorialExperimentConfig(ExperimentConfig):
method tag (line 75) | def tag(cls) -> str:
method create_model (line 102) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 124) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 134) | def train_task_sampler_args(
method valid_task_sampler_args (line 146) | def valid_task_sampler_args(
method test_task_sampler_args (line 158) | def test_task_sampler_args(
method _get_sampler_args (line 175) | def _get_sampler_args(
method machine_params (line 229) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
method training_pipeline (line 257) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
FILE: projects/tutorials/minigrid_offpolicy_tutorial.py
class BCOffPolicyBabyAIGoToLocalExperimentConfig (line 124) | class BCOffPolicyBabyAIGoToLocalExperimentConfig(BaseBabyAIGoToLocalExpe...
method tag (line 132) | def tag(cls):
method METRIC_ACCUMULATE_INTERVAL (line 136) | def METRIC_ACCUMULATE_INTERVAL(cls):
method training_pipeline (line 141) | def training_pipeline(cls, **kwargs):
FILE: projects/tutorials/minigrid_tutorial.py
class MiniGridTutorialExperimentConfig (line 100) | class MiniGridTutorialExperimentConfig(ExperimentConfig):
method tag (line 107) | def tag(cls) -> str:
method create_model (line 138) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 158) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 172) | def train_task_sampler_args(
method valid_task_sampler_args (line 182) | def valid_task_sampler_args(
method test_task_sampler_args (line 192) | def test_task_sampler_args(
method _get_sampler_args (line 208) | def _get_sampler_args(self, process_ind: int, mode: str) -> Dict[str, ...
method make_env (line 244) | def make_env(*args, **kwargs):
method machine_params (line 267) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
method training_pipeline (line 286) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
FILE: projects/tutorials/minigrid_tutorial_conds.py
class ConditionedLinearActorCriticHead (line 39) | class ConditionedLinearActorCriticHead(nn.Module):
method __init__ (line 40) | def __init__(
method lower_policy (line 54) | def lower_policy(self, *args, **kwargs):
method forward (line 61) | def forward(self, x):
class ConditionedLinearActorCritic (line 88) | class ConditionedLinearActorCritic(ActorCriticModel[SequentialDistr]):
method __init__ (line 89) | def __init__(
method _recurrent_memory_specification (line 116) | def _recurrent_memory_specification(self):
method forward (line 119) | def forward(self, observations, memory, prev_actions, masks):
class ConditionedRNNActorCritic (line 133) | class ConditionedRNNActorCritic(ActorCriticModel[SequentialDistr]):
method __init__ (line 134) | def __init__(
method recurrent_hidden_state_size (line 188) | def recurrent_hidden_state_size(self) -> int:
method num_recurrent_layers (line 192) | def num_recurrent_layers(self) -> int:
method _recurrent_memory_specification (line 195) | def _recurrent_memory_specification(self):
method forward (line 207) | def forward( # type:ignore
class ConditionedMiniGridSimpleConvRNN (line 235) | class ConditionedMiniGridSimpleConvRNN(MiniGridSimpleConvBase):
method __init__ (line 236) | def __init__(
method num_recurrent_layers (line 285) | def num_recurrent_layers(self):
method recurrent_hidden_state_size (line 289) | def recurrent_hidden_state_size(self):
method _recurrent_memory_specification (line 292) | def _recurrent_memory_specification(self):
class ConditionedMiniGridTask (line 305) | class ConditionedMiniGridTask(MiniGridTask):
method action_space (line 312) | def action_space(self) -> gym.spaces.Dict:
method _step (line 317) | def _step(self, action: Dict[str, int]) -> RLStepResult:
method query_expert (line 334) | def query_expert(self, **kwargs) -> Tuple[int, bool]:
class MiniGridTutorialExperimentConfig (line 354) | class MiniGridTutorialExperimentConfig(ExperimentConfig):
method tag (line 356) | def tag(cls) -> str:
method create_model (line 369) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 381) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 384) | def train_task_sampler_args(
method valid_task_sampler_args (line 394) | def valid_task_sampler_args(
method test_task_sampler_args (line 404) | def test_task_sampler_args(
method _get_sampler_args (line 414) | def _get_sampler_args(self, process_ind: int, mode: str) -> Dict[str, ...
method make_env (line 453) | def make_env(*args, **kwargs):
method machine_params (line 457) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
method training_pipeline (line 464) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
FILE: projects/tutorials/navtopartner_robothor_rgb_ppo.py
class NavToPartnerRoboThorRGBPPOExperimentConfig (line 35) | class NavToPartnerRoboThorRGBPPOExperimentConfig(ExperimentConfig):
method tag (line 82) | def tag(cls):
method training_pipeline (line 86) | def training_pipeline(cls, **kwargs):
method split_num_processes (line 119) | def split_num_processes(self, ndevices):
method get_viz (line 130) | def get_viz(self, mode):
method machine_params (line 150) | def machine_params(self, mode="train", **kwargs):
method create_model (line 179) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 193) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _partition_inds (line 198) | def _partition_inds(n: int, num_parts: int):
method _get_sampler_args_for_scene_split (line 203) | def _get_sampler_args_for_scene_split(
method train_task_sampler_args (line 242) | def train_task_sampler_args(
method valid_task_sampler_args (line 269) | def valid_task_sampler_args(
method test_task_sampler_args (line 297) | def test_task_sampler_args(
FILE: projects/tutorials/object_nav_ithor_dagger_then_ppo_one_object.py
class ObjectNavThorDaggerThenPPOExperimentConfig (line 21) | class ObjectNavThorDaggerThenPPOExperimentConfig(ObjectNavThorPPOExperim...
method tag (line 34) | def tag(cls):
method training_pipeline (line 38) | def training_pipeline(cls, **kwargs):
FILE: projects/tutorials/object_nav_ithor_dagger_then_ppo_one_object_viz.py
class ObjectNavThorDaggerThenPPOVizExperimentConfig (line 14) | class ObjectNavThorDaggerThenPPOVizExperimentConfig(
method tag (line 25) | def tag(cls):
method get_viz (line 30) | def get_viz(self, mode):
method machine_params (line 53) | def machine_params(self, mode="train", **kwargs):
FILE: projects/tutorials/object_nav_ithor_ppo_one_object.py
class ObjectNavThorPPOExperimentConfig (line 31) | class ObjectNavThorPPOExperimentConfig(ExperimentConfig):
method tag (line 67) | def tag(cls):
method training_pipeline (line 71) | def training_pipeline(cls, **kwargs):
method machine_params (line 111) | def machine_params(cls, mode="train", **kwargs):
method create_model (line 133) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 147) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _partition_inds (line 151) | def _partition_inds(n: int, num_parts: int):
method _get_sampler_args_for_scene_split (line 156) | def _get_sampler_args_for_scene_split(
method train_task_sampler_args (line 193) | def train_task_sampler_args(
method valid_task_sampler_args (line 218) | def valid_task_sampler_args(
method test_task_sampler_args (line 244) | def test_task_sampler_args(
FILE: projects/tutorials/pointnav_habitat_rgb_ddppo.py
class PointNavHabitatRGBPPOTutorialExperimentConfig (line 44) | class PointNavHabitatRGBPPOTutorialExperimentConfig(ExperimentConfig):
method tag (line 139) | def tag(cls):
method training_pipeline (line 143) | def training_pipeline(cls, **kwargs):
method machine_params (line 176) | def machine_params(self, mode="train", **kwargs):
method create_model (line 219) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 231) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 234) | def train_task_sampler_args(
method valid_task_sampler_args (line 251) | def valid_task_sampler_args(
method test_task_sampler_args (line 272) | def test_task_sampler_args(
FILE: projects/tutorials/pointnav_ithor_rgb_ddppo.py
class PointNaviThorRGBPPOExperimentConfig (line 39) | class PointNaviThorRGBPPOExperimentConfig(ExperimentConfig):
method tag (line 108) | def tag(cls):
method training_pipeline (line 112) | def training_pipeline(cls, **kwargs):
method machine_params (line 145) | def machine_params(self, mode="train", **kwargs):
method create_model (line 193) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 205) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _partition_inds (line 210) | def _partition_inds(n: int, num_parts: int):
method _get_sampler_args_for_scene_split (line 215) | def _get_sampler_args_for_scene_split(
method train_task_sampler_args (line 260) | def train_task_sampler_args(
method valid_task_sampler_args (line 287) | def valid_task_sampler_args(
method test_task_sampler_args (line 313) | def test_task_sampler_args(
FILE: projects/tutorials/running_inference_tutorial.py
class PointNavRoboThorRGBPPOVizExperimentConfig (line 119) | class PointNavRoboThorRGBPPOVizExperimentConfig(PointNavRoboThorRGBPPOEx...
method get_viz (line 138) | def get_viz(self, mode):
method machine_params (line 176) | def machine_params(self, mode="train", **kwargs):
FILE: projects/tutorials/training_a_pointnav_model.py
class PointNavRoboThorRGBPPOExperimentConfig (line 133) | class PointNavRoboThorRGBPPOExperimentConfig(ExperimentConfig):
method tag (line 296) | def tag(cls):
method training_pipeline (line 311) | def training_pipeline(cls, **kwargs):
method machine_params (line 351) | def machine_params(self, mode="train", **kwargs):
method create_model (line 410) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 431) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method _partition_inds (line 443) | def _partition_inds(n: int, num_parts: int):
method _get_sampler_args_for_scene_split (line 448) | def _get_sampler_args_for_scene_split(
method train_task_sampler_args (line 505) | def train_task_sampler_args(
method valid_task_sampler_args (line 532) | def valid_task_sampler_args(
method test_task_sampler_args (line 558) | def test_task_sampler_args(
FILE: scripts/build_docs.py
class StringColors (line 23) | class StringColors:
function render_file (line 46) | def render_file(
function build_docs_for_file (line 124) | def build_docs_for_file(
function build_docs (line 142) | def build_docs(
function project_readme_paths_to_nav_structure (line 197) | def project_readme_paths_to_nav_structure(project_readmes):
function pruned_nav_entries (line 230) | def pruned_nav_entries(nav_entries):
function main (line 254) | def main():
FILE: scripts/dcommand.py
function get_argument_parser (line 10) | def get_argument_parser():
function get_args (line 47) | def get_args():
function wrap_double (line 56) | def wrap_double(text):
function wrap_single (line 60) | def wrap_single(text):
function wrap_single_nested (line 64) | def wrap_single_nested(text, quote=r"'\''"):
FILE: scripts/dconfig.py
function get_argument_parser (line 7) | def get_argument_parser():
function get_args (line 53) | def get_args():
function wrap_double (line 62) | def wrap_double(text):
function wrap_single (line 66) | def wrap_single(text):
function wrap_single_nested (line 70) | def wrap_single_nested(text, quote=r"'\''"):
FILE: scripts/dkill.py
function get_argument_parser (line 10) | def get_argument_parser():
function get_args (line 39) | def get_args():
FILE: scripts/dmain.py
function get_argument_parser (line 23) | def get_argument_parser():
function get_args (line 67) | def get_args():
function get_raw_args (line 76) | def get_raw_args():
function wrap_single (line 109) | def wrap_single(text):
function wrap_single_nested (line 113) | def wrap_single_nested(text):
function wrap_double (line 121) | def wrap_double(text):
function id_generator (line 125) | def id_generator(size=4, chars=string.ascii_uppercase + string.digits):
FILE: scripts/literate.py
function get_literate_output_path (line 13) | def get_literate_output_path(file: TextIO) -> Optional[str]:
function source_to_markdown (line 42) | def source_to_markdown(dot_path: str, summarize: bool = False):
function _strip_empty_lines (line 83) | def _strip_empty_lines(lines: Sequence[str]) -> List[str]:
function literate_python_to_markdown (line 100) | def literate_python_to_markdown(path: str) -> bool:
FILE: scripts/release.py
function make_package (line 7) | def make_package(name, verbose=False):
FILE: scripts/startx.py
function pci_records (line 14) | def pci_records():
function generate_xorg_conf (line 28) | def generate_xorg_conf(devices):
function startx (line 68) | def startx(display=0):
FILE: tests/hierarchical_policies/test_minigrid_conditional.py
class MiniGridCondTestExperimentConfig (line 30) | class MiniGridCondTestExperimentConfig(ExperimentConfig):
method tag (line 32) | def tag(cls) -> str:
method create_model (line 45) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 57) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method train_task_sampler_args (line 60) | def train_task_sampler_args(
method valid_task_sampler_args (line 70) | def valid_task_sampler_args(
method test_task_sampler_args (line 80) | def test_task_sampler_args(
method _get_sampler_args (line 90) | def _get_sampler_args(self, process_ind: int, mode: str) -> Dict[str, ...
method make_env (line 129) | def make_env(*args, **kwargs):
method machine_params (line 133) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
method training_pipeline (line 140) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
class TestMiniGridCond (line 177) | class TestMiniGridCond:
method test_train (line 178) | def test_train(self, tmpdir):
FILE: tests/manipulathor_plugin/test_utils.py
class TestArmCalculationUtils (line 6) | class TestArmCalculationUtils(object):
method test_translation_functions (line 7) | def test_translation_functions(self):
FILE: tests/mapping/test_ai2thor_mapping.py
class TestAI2THORMapSensors (line 40) | class TestAI2THORMapSensors(object):
method setup_path_for_use_with_rearrangement_project (line 41) | def setup_path_for_use_with_rearrangement_project(self) -> bool:
method test_binned_and_semantic_mapping (line 66) | def test_binned_and_semantic_mapping(self, tmpdir):
method test_pretrained_rearrange_walkthrough_mapping_agent (line 315) | def test_pretrained_rearrange_walkthrough_mapping_agent(self, tmpdir):
FILE: tests/multiprocessing/test_frozen_attribs.py
class MyConfig (line 12) | class MyConfig(ExperimentConfig):
method tag (line 16) | def tag(cls) -> str:
method training_pipeline (line 20) | def training_pipeline(cls, **kwargs) -> TrainingPipeline:
method create_model (line 24) | def create_model(cls, **kwargs) -> nn.Module:
method make_sampler_fn (line 28) | def make_sampler_fn(cls, **kwargs) -> TaskSampler:
method my_var_is (line 31) | def my_var_is(self, val):
class MySpecConfig (line 36) | class MySpecConfig(MyConfig):
method machine_params (line 40) | def machine_params(cls, mode="train", **kwargs) -> Dict[str, Any]:
method tag (line 44) | def tag(cls) -> str:
class TestFrozenAttribs (line 51) | class TestFrozenAttribs(object):
method test_frozen_inheritance (line 52) | def test_frozen_inheritance(self):
method my_func (line 83) | def my_func(config, val):
method test_frozen_experiment_config (line 86) | def test_frozen_experiment_config(self):
FILE: tests/sync_algs_cpu/test_to_to_obj_trains.py
class FixedConstantLoss (line 37) | class FixedConstantLoss(AbstractActorCriticLoss):
method __init__ (line 38) | def __init__(self, name: str, value: float):
method loss (line 43) | def loss( # type: ignore
class SillyStorage (line 51) | class SillyStorage(ExperienceStorage, StreamingStorageMixin):
method __init__ (line 52) | def __init__(self, values_to_return: List[float], repeats: List[int]):
method initialize (line 58) | def initialize(self, *, observations: ObservationType, **kwargs):
method add (line 61) | def add(
method to (line 73) | def to(self, device: torch.device):
method set_partition (line 76) | def set_partition(self, index: int, num_parts: int):
method total_experiences (line 80) | def total_experiences(self) -> int:
method total_experiences (line 84) | def total_experiences(self, value: int):
method next_batch (line 87) | def next_batch(self) -> Dict[str, Any]:
method reset_stream (line 99) | def reset_stream(self):
method empty (line 102) | def empty(self) -> bool:
class AverageBatchValueLoss (line 106) | class AverageBatchValueLoss(GenericAbstractLoss):
method loss (line 107) | def loss(
class PPOBabyAIGoToObjTestExperimentConfig (line 126) | class PPOBabyAIGoToObjTestExperimentConfig(PPOBabyAIGoToObjExperimentCon...
method tag (line 130) | def tag(cls):
method machine_params (line 134) | def machine_params(cls, mode="train", **kwargs):
method training_pipeline (line 148) | def training_pipeline(cls, **kwargs):
method valid_task_sampler_args (line 206) | def valid_task_sampler_args(
class RedirectOutput (line 220) | class RedirectOutput:
method __init__ (line 221) | def __init__(self, capsys: Optional, capfd: Optional):
method get_output (line 232) | def get_output(self):
method __enter__ (line 235) | def __enter__(self):
method __exit__ (line 247) | def __exit__(self, *args):
class TestGoToObjTrains (line 261) | class TestGoToObjTrains:
method test_ppo_trains (line 262) | def test_ppo_trains(self, capfd, tmpdir):
FILE: tests/utils/test_inference_agent.py
class TestInferenceAgent (line 46) | class TestInferenceAgent(object):
method test_inference_agent_from_minigrid_config (line 47) | def test_inference_agent_from_minigrid_config(self):
FILE: tests/utils/test_spaces.py
class TestSpaces (line 12) | class TestSpaces(object):
method same (line 32) | def same(a, b, bidx=None):
method test_conversion (line 50) | def test_conversion(self):
method test_flatten (line 59) | def test_flatten(self):
method test_batched (line 86) | def test_batched(self):
method test_tolist (line 100) | def test_tolist(self):
FILE: tests/vision/test_pillow_rescaling.py
class TestPillowRescaling (line 14) | class TestPillowRescaling(object):
method _load_thor_img (line 15) | def _load_thor_img(self) -> np.ndarray:
method _get_img_hash (line 22) | def _get_img_hash(self, img: np.ndarray) -> str:
method _random_rgb_image (line 26) | def _random_rgb_image(self, w
Condensed preview — 402 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,188K chars).
[
{
"path": ".VERSION",
"chars": 7,
"preview": "0.5.5a\n"
},
{
"path": ".github/ISSUE_TEMPLATE/bug_report.md",
"chars": 674,
"preview": "---\nname: Bug report\nabout: Create a report to help us improve\ntitle: ''\nlabels: bug\nassignees: ''\n\n---\n\n## Problem\n\nA c"
},
{
"path": ".github/ISSUE_TEMPLATE/feature_request.md",
"chars": 608,
"preview": "---\nname: Feature request\nabout: Suggest an enhancement or a new feature\ntitle: ''\nlabels: enhancement\nassignees: ''\n\n--"
},
{
"path": ".github/ISSUE_TEMPLATE/support_request.md",
"chars": 380,
"preview": "---\nname: Support request\nabout: Request support regarding AllenAct\ntitle: ''\nlabels: ''\nassignees: ''\n\n---\n\n## Problem "
},
{
"path": ".github/workflows/black.yml",
"chars": 155,
"preview": "name: Lint\n\non: [push, pull_request]\n\njobs:\n lint:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout"
},
{
"path": ".github/workflows/codeql.yml",
"chars": 833,
"preview": "name: \"CodeQL\"\n\non:\n push:\n branches: [ \"main\" ]\n pull_request:\n branches: [ \"main\" ]\n schedule:\n - cron: \"1"
},
{
"path": ".github/workflows/publish.yml",
"chars": 830,
"preview": "# This workflow will upload the allenact and allenact_plugins packages using Twine (after manually triggering it)\n# For "
},
{
"path": ".github/workflows/pytest.yml",
"chars": 1180,
"preview": "name: PyTest\n\non: [push]\n\njobs:\n build:\n\n runs-on: ubuntu-latest\n strategy:\n matrix:\n python-version:"
},
{
"path": ".gitignore",
"chars": 2590,
"preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
},
{
"path": ".gitmodules",
"chars": 169,
"preview": "[submodule \"projects/ithor_rearrangement\"]\n\tpath = projects/ithor_rearrangement\n\turl = https://github.com/allenai/ai2tho"
},
{
"path": ".pre-commit-config.yaml",
"chars": 303,
"preview": "repos:\n- repo: https://github.com/ambv/black\n rev: 19.10b0\n hooks:\n - id: black\n language_version: pytho"
},
{
"path": "CNAME",
"chars": 16,
"preview": "www.allenact.org"
},
{
"path": "CONTRIBUTING.md",
"chars": 3268,
"preview": "# Contributing\n\nWe welcome contributions from the greater community. If you would like to make such a contributions we r"
},
{
"path": "LICENSE",
"chars": 1227,
"preview": "MIT License\n\nOriginal work Copyright (c) 2017 Ilya Kostrikov\n\nOriginal work Copyright (c) Facebook, Inc. and its affilia"
},
{
"path": "README.md",
"chars": 6098,
"preview": "<div align=\"center\">\n <img src=\"docs/img/AllenAct.svg\" width=\"350\" />\n <br>\n <i><h3>An open source framework fo"
},
{
"path": "ROADMAP.md",
"chars": 429,
"preview": "# Roadmap\n\nHere we track new features/support to be added in the short/mid-term. \n\n## New environments\n* [SAPIEN](https"
},
{
"path": "allenact/__init__.py",
"chars": 162,
"preview": "try:\n # noinspection PyProtectedMember,PyUnresolvedReferences\n from allenact._version import __version__\nexcept Mo"
},
{
"path": "allenact/_constants.py",
"chars": 108,
"preview": "import os\nfrom pathlib import Path\n\nALLENACT_INSTALL_DIR = os.path.abspath(os.path.dirname(Path(__file__)))\n"
},
{
"path": "allenact/algorithms/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/algorithms/offpolicy_sync/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/algorithms/offpolicy_sync/losses/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/algorithms/offpolicy_sync/losses/abstract_offpolicy_loss.py",
"chars": 1446,
"preview": "\"\"\"Defining abstract loss classes for actor critic models.\"\"\"\n\nimport abc\nfrom typing import Dict, Tuple, TypeVar, Gener"
},
{
"path": "allenact/algorithms/onpolicy_sync/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/algorithms/onpolicy_sync/engine.py",
"chars": 103110,
"preview": "\"\"\"Defines the reinforcement learning `OnPolicyRLEngine`.\"\"\"\n\nimport datetime\nimport logging\nimport numbers\nimport os\nim"
},
{
"path": "allenact/algorithms/onpolicy_sync/losses/__init__.py",
"chars": 64,
"preview": "from .a2cacktr import A2C, ACKTR, A2CACKTR\nfrom .ppo import PPO\n"
},
{
"path": "allenact/algorithms/onpolicy_sync/losses/a2cacktr.py",
"chars": 5233,
"preview": "\"\"\"Implementation of A2C and ACKTR losses.\"\"\"\n\nfrom typing import cast, Tuple, Dict, Optional\n\nimport torch\n\nfrom allena"
},
{
"path": "allenact/algorithms/onpolicy_sync/losses/abstract_loss.py",
"chars": 1972,
"preview": "\"\"\"Defining abstract loss classes for actor critic models.\"\"\"\n\nimport abc\nfrom typing import Dict, Tuple, Union\n\nimport "
},
{
"path": "allenact/algorithms/onpolicy_sync/losses/grouped_action_imitation.py",
"chars": 2526,
"preview": "import functools\nfrom typing import Dict, cast, Sequence, Set\n\nimport torch\n\nfrom allenact.algorithms.onpolicy_sync.loss"
},
{
"path": "allenact/algorithms/onpolicy_sync/losses/imitation.py",
"chars": 8153,
"preview": "\"\"\"Defining imitation losses for actor critic type models.\"\"\"\n\nfrom collections import OrderedDict\nfrom typing import Di"
},
{
"path": "allenact/algorithms/onpolicy_sync/losses/ppo.py",
"chars": 7715,
"preview": "\"\"\"Defining the PPO loss for actor critic type models.\"\"\"\n\nfrom typing import Dict, Optional, Callable, cast, Tuple\n\nimp"
},
{
"path": "allenact/algorithms/onpolicy_sync/misc.py",
"chars": 435,
"preview": "from enum import Enum\nfrom typing import Dict, Any, Optional\n\nimport attr\n\n\nclass TrackingInfoType(Enum):\n LOSS = \"lo"
},
{
"path": "allenact/algorithms/onpolicy_sync/policy.py",
"chars": 7192,
"preview": "#!/usr/bin/env python3\n\n# Copyright (c) Facebook, Inc. and its affiliates.\n# This source code is licensed under the MIT "
},
{
"path": "allenact/algorithms/onpolicy_sync/runner.py",
"chars": 65810,
"preview": "\"\"\"Defines the reinforcement learning `OnPolicyRunner`.\"\"\"\n\nimport copy\nimport enum\nimport glob\nimport importlib.util\nim"
},
{
"path": "allenact/algorithms/onpolicy_sync/storage.py",
"chars": 25290,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/algorithms/onpolicy_sync/vector_sampled_tasks.py",
"chars": 49749,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/base_abstractions/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/base_abstractions/callbacks.py",
"chars": 1879,
"preview": "import abc\nfrom typing import List, Dict, Any, Sequence, Optional\n\nfrom allenact.base_abstractions.experiment_config imp"
},
{
"path": "allenact/base_abstractions/distributions.py",
"chars": 13352,
"preview": "import abc\nfrom collections import OrderedDict\nfrom typing import Any, Union, Callable, TypeVar, Dict, Optional, cast, P"
},
{
"path": "allenact/base_abstractions/experiment_config.py",
"chars": 11245,
"preview": "\"\"\"Defines the `ExperimentConfig` abstract class used as the basis of all\nexperiments.\"\"\"\n\nimport abc\nfrom typing import"
},
{
"path": "allenact/base_abstractions/misc.py",
"chars": 14854,
"preview": "import abc\nfrom typing import (\n Dict,\n Any,\n TypeVar,\n Sequence,\n NamedTuple,\n Optional,\n List,\n "
},
{
"path": "allenact/base_abstractions/preprocessor.py",
"chars": 6890,
"preview": "import abc\nfrom typing import List, Any, Dict\nfrom typing import Sequence\nfrom typing import Union\n\nimport gym\nimport ne"
},
{
"path": "allenact/base_abstractions/sensor.py",
"chars": 14442,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/base_abstractions/task.py",
"chars": 12653,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/embodiedai/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/aux_losses/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/aux_losses/losses.py",
"chars": 27976,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/embodiedai/mapping/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/mapping/mapping_losses.py",
"chars": 6420,
"preview": "import torch\nfrom torch.nn import functional as F\n\nfrom allenact.algorithms.onpolicy_sync.losses.abstract_loss import (\n"
},
{
"path": "allenact/embodiedai/mapping/mapping_models/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/mapping/mapping_models/active_neural_slam.py",
"chars": 30058,
"preview": "# MIT License\n#\n# Original Copyright (c) 2020 Devendra Chaplot\n#\n# Modified work Copyright (c) 2021 Allen Institute for "
},
{
"path": "allenact/embodiedai/mapping/mapping_utils/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/mapping/mapping_utils/map_builders.py",
"chars": 26713,
"preview": "# MIT License\n#\n# Original Copyright (c) 2020 Devendra Chaplot\n#\n# Modified work Copyright (c) 2021 Allen Institute for "
},
{
"path": "allenact/embodiedai/mapping/mapping_utils/point_cloud_utils.py",
"chars": 20076,
"preview": "# MIT License\n#\n# Original Copyright (c) 2020 Devendra Chaplot\n#\n# Modified work Copyright (c) 2021 Allen Institute for "
},
{
"path": "allenact/embodiedai/models/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/models/aux_models.py",
"chars": 4108,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/embodiedai/models/basic_models.py",
"chars": 25260,
"preview": "\"\"\"Basic building block torch networks that can be used across a variety of\ntasks.\"\"\"\n\nfrom typing import (\n Sequence"
},
{
"path": "allenact/embodiedai/models/fusion_models.py",
"chars": 4021,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/embodiedai/models/resnet.py",
"chars": 12672,
"preview": "# Original work Copyright (c) Facebook, Inc. and its affiliates.\n# Modified work Copyright (c) Allen Institute for AI\n# "
},
{
"path": "allenact/embodiedai/models/visual_nav_models.py",
"chars": 10694,
"preview": "from collections import OrderedDict\nfrom typing import Tuple, Dict, Optional, List, Sequence\nfrom typing import TypeVar\n"
},
{
"path": "allenact/embodiedai/preprocessors/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/preprocessors/resnet.py",
"chars": 3438,
"preview": "from typing import List, Callable, Optional, Any, cast, Dict\n\nimport gym\nimport numpy as np\nimport torch\nimport torch.nn"
},
{
"path": "allenact/embodiedai/sensors/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/sensors/vision_sensors.py",
"chars": 13335,
"preview": "from abc import abstractmethod, ABC\nfrom typing import Optional, Tuple, Any, cast, Union, Sequence\n\nimport PIL\nimport gy"
},
{
"path": "allenact/embodiedai/storage/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/embodiedai/storage/vdr_storage.py",
"chars": 7504,
"preview": "import math\nimport random\nfrom collections import defaultdict\nfrom typing import Union, Tuple, Optional, Dict, Callable,"
},
{
"path": "allenact/main.py",
"chars": 18510,
"preview": "\"\"\"Entry point to training/validating/testing for a user given experiment\nname.\"\"\"\n\nimport os\n\nif \"CUDA_DEVICE_ORDER\" no"
},
{
"path": "allenact/setup.py",
"chars": 4438,
"preview": "import os\nfrom pathlib import Path\n\nfrom setuptools import find_packages, setup\n\n\ndef parse_req_file(fname, initial=None"
},
{
"path": "allenact/utils/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact/utils/cache_utils.py",
"chars": 5772,
"preview": "import math\nfrom typing import Dict, Any, Union, Callable, Optional\n\nfrom allenact.utils.system import get_logger\n\n\ndef "
},
{
"path": "allenact/utils/cacheless_frcnn.py",
"chars": 2680,
"preview": "from typing import List, Any\n\nimport torch\nfrom torchvision.models.detection.backbone_utils import resnet_fpn_backbone\nf"
},
{
"path": "allenact/utils/experiment_utils.py",
"chars": 46829,
"preview": "\"\"\"Utility classes and functions for running and designing experiments.\"\"\"\n\nimport abc\nimport collections.abc\nimport cop"
},
{
"path": "allenact/utils/inference.py",
"chars": 5243,
"preview": "from typing import Optional, cast, Tuple, Any, Dict\n\nimport attr\nimport torch\n\nfrom allenact.algorithms.onpolicy_sync.po"
},
{
"path": "allenact/utils/misc_utils.py",
"chars": 10156,
"preview": "import copy\nimport functools\nimport hashlib\nimport inspect\nimport json\nimport math\nimport os\nimport pdb\nimport random\nim"
},
{
"path": "allenact/utils/model_utils.py",
"chars": 7918,
"preview": "\"\"\"Functions used to initialize and manipulate pytorch models.\"\"\"\n\nimport hashlib\nfrom typing import Sequence, Tuple, Un"
},
{
"path": "allenact/utils/multi_agent_viz_utils.py",
"chars": 4501,
"preview": "from typing import Sequence, Any\n\nimport numpy as np\nfrom matplotlib import pyplot as plt, markers\nfrom matplotlib.colle"
},
{
"path": "allenact/utils/spaces_utils.py",
"chars": 8839,
"preview": "# Original work Copyright (c) 2016 OpenAI (https://openai.com).\n# Modified work Copyright (c) Allen Institute for AI\n# T"
},
{
"path": "allenact/utils/system.py",
"chars": 7148,
"preview": "import io\nimport logging\nimport os\nimport socket\nimport sys\nfrom contextlib import closing\nfrom typing import cast, Opti"
},
{
"path": "allenact/utils/tensor_utils.py",
"chars": 16073,
"preview": "\"\"\"Functions used to manipulate pytorch tensors and numpy arrays.\"\"\"\n\nimport numbers\nimport os\nimport tempfile\nfrom coll"
},
{
"path": "allenact/utils/viz_utils.py",
"chars": 45775,
"preview": "import abc\nimport json\nimport os\nimport sys\nfrom collections import defaultdict\nfrom typing import (\n Dict,\n Any,\n"
},
{
"path": "allenact_plugins/__init__.py",
"chars": 170,
"preview": "try:\n # noinspection PyProtectedMember,PyUnresolvedReferences\n from allenact_plugins._version import __version__\ne"
},
{
"path": "allenact_plugins/babyai_plugin/__init__.py",
"chars": 294,
"preview": "from allenact.utils.system import ImportChecker\n\nwith ImportChecker(\n \"\\n\\nPlease install babyai with:\\n\\n\"\n \"pip "
},
{
"path": "allenact_plugins/babyai_plugin/babyai_constants.py",
"chars": 155,
"preview": "import os\nfrom pathlib import Path\n\nBABYAI_EXPERT_TRAJECTORIES_DIR = os.path.abspath(\n os.path.join(os.path.dirname(P"
},
{
"path": "allenact_plugins/babyai_plugin/babyai_models.py",
"chars": 24510,
"preview": "from typing import Dict, Optional, List, cast, Tuple, Any\n\nimport babyai.model\nimport babyai.rl\nimport gym\nimport numpy "
},
{
"path": "allenact_plugins/babyai_plugin/babyai_tasks.py",
"chars": 7764,
"preview": "import random\nimport signal\nfrom typing import Tuple, Any, List, Dict, Optional, Union, Callable\n\nimport babyai\nimport b"
},
{
"path": "allenact_plugins/babyai_plugin/configs/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/babyai_plugin/data/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/babyai_plugin/extra_environment.yml",
"chars": 161,
"preview": "dependencies:\n - networkx\n - pip\n - pip:\n - \"--editable=git+https://github.com/Lucaweihs/babyai.git@0b450eeb3a2d"
},
{
"path": "allenact_plugins/babyai_plugin/extra_requirements.txt",
"chars": 102,
"preview": "babyai @ git+https://github.com/Lucaweihs/babyai.git@0b450eeb3a2dc7116c67900d51391986bdbb84cd\nnetworkx"
},
{
"path": "allenact_plugins/babyai_plugin/scripts/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/babyai_plugin/scripts/download_babyai_expert_demos.py",
"chars": 3758,
"preview": "import argparse\nimport os\nimport platform\n\nfrom allenact_plugins.babyai_plugin.babyai_constants import (\n BABYAI_EXPE"
},
{
"path": "allenact_plugins/babyai_plugin/scripts/get_instr_length_percentiles.py",
"chars": 735,
"preview": "import glob\nimport os\n\nimport babyai\nimport numpy as np\n\nfrom allenact_plugins.babyai_plugin.babyai_constants import (\n "
},
{
"path": "allenact_plugins/babyai_plugin/scripts/truncate_expert_demos.py",
"chars": 846,
"preview": "import glob\nimport os\n\nimport babyai\n\nfrom allenact_plugins.babyai_plugin.babyai_constants import (\n BABYAI_EXPERT_TR"
},
{
"path": "allenact_plugins/clip_plugin/__init__.py",
"chars": 317,
"preview": "from allenact.utils.system import ImportChecker\n\nwith ImportChecker(\n \"Cannot `import clip`. Please install clip from"
},
{
"path": "allenact_plugins/clip_plugin/clip_preprocessors.py",
"chars": 8591,
"preview": "from typing import List, Optional, Any, cast, Dict, Tuple\n\nimport clip\nimport gym\nimport numpy as np\nimport torch\nimport"
},
{
"path": "allenact_plugins/clip_plugin/extra_environment.yml",
"chars": 259,
"preview": "channels:\n - pytorch\n - defaults\n - conda-forge\ndependencies:\n - pytorch>=1.7.1\n - torchvision\n - pip:\n - ftf"
},
{
"path": "allenact_plugins/clip_plugin/extra_requirements.txt",
"chars": 133,
"preview": "torch>=1.7.1\ntorchvision\nftfy\nregex\ntqdm\nclip @ git+https://github.com/openai/clip@e184f608c5d5e58165682f7c332c3a8b4c154"
},
{
"path": "allenact_plugins/gym_plugin/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/gym_plugin/extra_environment.yml",
"chars": 83,
"preview": "channels:\n - defaults\n - conda-forge\ndependencies:\n - gym-box2d>=0.17.0,<0.20.0\n"
},
{
"path": "allenact_plugins/gym_plugin/extra_requirements.txt",
"chars": 27,
"preview": "gym[box2d]>=0.17.0,<0.20.0\n"
},
{
"path": "allenact_plugins/gym_plugin/gym_distributions.py",
"chars": 263,
"preview": "import torch\n\nfrom allenact.base_abstractions.distributions import Distr\n\n\nclass GaussianDistr(torch.distributions.Norma"
},
{
"path": "allenact_plugins/gym_plugin/gym_environment.py",
"chars": 811,
"preview": "from typing import Optional\n\nimport gym\nimport numpy as np\n\n\nclass GymEnvironment(gym.Wrapper):\n \"\"\"gym.Wrapper with "
},
{
"path": "allenact_plugins/gym_plugin/gym_models.py",
"chars": 2641,
"preview": "from typing import Dict, Union, Optional, Tuple, Any, Sequence, cast\n\nimport gym\nimport torch\nimport torch.nn as nn\n\nfro"
},
{
"path": "allenact_plugins/gym_plugin/gym_sensors.py",
"chars": 4157,
"preview": "from typing import Optional, Any\n\nimport gym\nimport numpy as np\n\nfrom allenact.base_abstractions.sensor import Sensor, p"
},
{
"path": "allenact_plugins/gym_plugin/gym_tasks.py",
"chars": 10422,
"preview": "import random\nfrom typing import Any, List, Dict, Optional, Union, Callable, Sequence, Tuple\n\nimport gym\nimport numpy as"
},
{
"path": "allenact_plugins/habitat_plugin/__init__.py",
"chars": 253,
"preview": "from allenact.utils.system import ImportChecker\n\nwith ImportChecker(\n \"\\n\\nPlease install habitat following\\n\\n\"\n "
},
{
"path": "allenact_plugins/habitat_plugin/data/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/habitat_plugin/extra_environment.yml",
"chars": 292,
"preview": "channels:\n - defaults\n - conda-forge\n - aihabitat\ndependencies:\n - habitat-sim=0.1.5\n - numba\n - pip\n - pip:\n "
},
{
"path": "allenact_plugins/habitat_plugin/extra_environment_headless.yml",
"chars": 305,
"preview": "channels:\n - defaults\n - conda-forge\n - aihabitat\ndependencies:\n - habitat-sim=0.1.5\n - headless\n - numba\n - pip\n"
},
{
"path": "allenact_plugins/habitat_plugin/extra_requirements.txt",
"chars": 150,
"preview": "habitat @ git+https://github.com/facebookresearch/habitat-lab.git@33654923dc733f5fcea23aea6391034c3f694a67\nnumpy-quatern"
},
{
"path": "allenact_plugins/habitat_plugin/habitat_constants.py",
"chars": 1213,
"preview": "import os\n\nHABITAT_BASE = os.getenv(\n \"HABITAT_BASE_DIR\",\n default=os.path.join(os.getcwd(), \"external_projects\", "
},
{
"path": "allenact_plugins/habitat_plugin/habitat_environment.py",
"chars": 2646,
"preview": "\"\"\"A wrapper for interacting with the Habitat environment.\"\"\"\n\nimport os\nfrom typing import Dict, Union, List, Optional\n"
},
{
"path": "allenact_plugins/habitat_plugin/habitat_preprocessors.py",
"chars": 1,
"preview": "\n"
},
{
"path": "allenact_plugins/habitat_plugin/habitat_sensors.py",
"chars": 5293,
"preview": "from typing import Any, Optional, Tuple, TYPE_CHECKING\n\nimport gym\nimport numpy as np\nfrom pyquaternion import Quaternio"
},
{
"path": "allenact_plugins/habitat_plugin/habitat_task_samplers.py",
"chars": 8327,
"preview": "from typing import List, Optional, Union, Callable, Any, Dict, Type\n\nimport gym\n\nimport habitat\nfrom allenact.base_abstr"
},
{
"path": "allenact_plugins/habitat_plugin/habitat_tasks.py",
"chars": 15168,
"preview": "from abc import ABC\nfrom typing import Tuple, List, Dict, Any, Optional, Union, Sequence, cast\n\nimport gym\nimport numpy "
},
{
"path": "allenact_plugins/habitat_plugin/habitat_utils.py",
"chars": 8187,
"preview": "import os\nfrom typing import List\n\nimport habitat\nfrom allenact_plugins.habitat_plugin.habitat_constants import (\n HA"
},
{
"path": "allenact_plugins/habitat_plugin/scripts/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/habitat_plugin/scripts/agent_demo.py",
"chars": 2373,
"preview": "import os\n\nimport cv2\nimport habitat\nfrom pyquaternion import Quaternion\n\nfrom allenact_plugins.habitat_plugin.habitat_c"
},
{
"path": "allenact_plugins/habitat_plugin/scripts/make_map.py",
"chars": 1639,
"preview": "import os\n\nimport habitat\nimport numpy as np\nfrom tqdm import tqdm\n\nfrom allenact_plugins.habitat_plugin.habitat_constan"
},
{
"path": "allenact_plugins/ithor_plugin/__init__.py",
"chars": 214,
"preview": "from allenact.utils.system import ImportChecker\n\nwith ImportChecker(\n \"Cannot `import ai2thor`, please install `ai2th"
},
{
"path": "allenact_plugins/ithor_plugin/extra_environment.yml",
"chars": 197,
"preview": "channels:\n - defaults\n - conda-forge\ndependencies:\n - ai2thor>=2.5.3\n - numba\n - pip\n - colour\n - packaging\n - p"
},
{
"path": "allenact_plugins/ithor_plugin/extra_requirements.txt",
"chars": 87,
"preview": "ai2thor>=2.5.3\nnumpy-quaternion\npyquaternion>=0.9.9\ncolour\nnumba\npackaging\npython-xlib\n"
},
{
"path": "allenact_plugins/ithor_plugin/ithor_constants.py",
"chars": 5611,
"preview": "\"\"\"Common constants used when training agents to complete tasks in iTHOR, the\ninteractive version of AI2-THOR.\"\"\"\n\nfrom "
},
{
"path": "allenact_plugins/ithor_plugin/ithor_environment.py",
"chars": 43194,
"preview": "\"\"\"A wrapper for engaging with the THOR environment.\"\"\"\n\nimport copy\nimport functools\nimport math\nimport random\nfrom typ"
},
{
"path": "allenact_plugins/ithor_plugin/ithor_sensors.py",
"chars": 20356,
"preview": "import copy\nfrom functools import reduce\nfrom typing import Any, Dict, Optional, Union, Sequence\n\nimport ai2thor.control"
},
{
"path": "allenact_plugins/ithor_plugin/ithor_task_samplers.py",
"chars": 6556,
"preview": "import copy\nimport random\nfrom typing import List, Dict, Optional, Any, Union, cast\n\nimport gym\n\nfrom allenact.base_abst"
},
{
"path": "allenact_plugins/ithor_plugin/ithor_tasks.py",
"chars": 9987,
"preview": "import random\nfrom typing import Dict, Tuple, List, Any, Optional, Union, Sequence, cast\n\nimport gym\nimport numpy as np\n"
},
{
"path": "allenact_plugins/ithor_plugin/ithor_util.py",
"chars": 2956,
"preview": "import glob\nimport math\nimport os\nimport platform\nimport traceback\nimport warnings\nfrom contextlib import contextmanager"
},
{
"path": "allenact_plugins/ithor_plugin/ithor_viz.py",
"chars": 15676,
"preview": "import copy\nimport json\nimport math\nimport os\nfrom typing import Tuple, Sequence, Union, Dict, Optional, Any, cast, Gene"
},
{
"path": "allenact_plugins/ithor_plugin/scripts/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/ithor_plugin/scripts/make_objectnav_debug_dataset.py",
"chars": 660,
"preview": "import os\n\nfrom allenact_plugins.robothor_plugin.scripts.make_objectnav_debug_dataset import (\n create_debug_dataset_"
},
{
"path": "allenact_plugins/ithor_plugin/scripts/make_pointnav_debug_dataset.py",
"chars": 634,
"preview": "import os\n\nfrom allenact_plugins.robothor_plugin.scripts.make_objectnav_debug_dataset import (\n create_debug_dataset_"
},
{
"path": "allenact_plugins/lighthouse_plugin/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/lighthouse_plugin/configs/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/lighthouse_plugin/data/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/lighthouse_plugin/extra_environment.yml",
"chars": 76,
"preview": "dependencies:\n - patsy>=0.5.1\n - pip\n - pip:\n - gym-minigrid>=1.0.1\n"
},
{
"path": "allenact_plugins/lighthouse_plugin/extra_requirements.txt",
"chars": 33,
"preview": "patsy>=0.5.1\ngym-minigrid>=1.0.1\n"
},
{
"path": "allenact_plugins/lighthouse_plugin/lighthouse_environment.py",
"chars": 10096,
"preview": "import copy\nimport curses\nimport itertools\nimport time\nfrom functools import lru_cache\nfrom typing import Optional, Tupl"
},
{
"path": "allenact_plugins/lighthouse_plugin/lighthouse_models.py",
"chars": 2841,
"preview": "from typing import Optional, Tuple, cast\n\nimport gym\nimport torch\nimport torch.nn as nn\nfrom gym.spaces.dict import Dict"
},
{
"path": "allenact_plugins/lighthouse_plugin/lighthouse_sensors.py",
"chars": 9070,
"preview": "import itertools\nfrom typing import Any, Dict, Optional, Tuple, Sequence\n\nimport gym\nimport numpy as np\nimport pandas as"
},
{
"path": "allenact_plugins/lighthouse_plugin/lighthouse_tasks.py",
"chars": 14355,
"preview": "import abc\nimport string\nfrom typing import List, Dict, Any, Optional, Tuple, Union, Sequence, cast\n\nimport gym\nimport n"
},
{
"path": "allenact_plugins/lighthouse_plugin/lighthouse_util.py",
"chars": 1860,
"preview": "import numpy as np\n\nfrom allenact.utils.experiment_utils import EarlyStoppingCriterion, ScalarMeanTracker\n\n\nclass StopIf"
},
{
"path": "allenact_plugins/lighthouse_plugin/scripts/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/manipulathor_plugin/__init__.py",
"chars": 214,
"preview": "from allenact.utils.system import ImportChecker\n\nwith ImportChecker(\n \"Cannot `import ai2thor`, please install `ai2th"
},
{
"path": "allenact_plugins/manipulathor_plugin/arm_calculation_utils.py",
"chars": 4597,
"preview": "\"\"\"Utility classes and functions for calculating the arm relative and absolute\nposition.\"\"\"\n\nfrom typing import Dict\n\nim"
},
{
"path": "allenact_plugins/manipulathor_plugin/armpointnav_constants.py",
"chars": 912,
"preview": "import json\nimport os\nfrom typing import Dict, Optional, Any\n\nfrom constants import ABS_PATH_OF_TOP_LEVEL_DIR\n\nTRAIN_OBJ"
},
{
"path": "allenact_plugins/manipulathor_plugin/manipulathor_constants.py",
"chars": 1741,
"preview": "\"\"\"Constant values and hyperparameters that are used by the environment.\"\"\"\n\nimport ai2thor.fifo_server\n\n\nARM_MIN_HEIGHT"
},
{
"path": "allenact_plugins/manipulathor_plugin/manipulathor_environment.py",
"chars": 19585,
"preview": "\"\"\"A wrapper for engaging with the ManipulaTHOR environment.\"\"\"\n\nimport copy\nimport math\nimport warnings\nfrom typing imp"
},
{
"path": "allenact_plugins/manipulathor_plugin/manipulathor_sensors.py",
"chars": 10597,
"preview": "\"\"\"Utility classes and functions for sensory inputs used by the models.\"\"\"\n\nfrom typing import Any, Union, Optional\n\nimp"
},
{
"path": "allenact_plugins/manipulathor_plugin/manipulathor_task_samplers.py",
"chars": 18369,
"preview": "\"\"\"Task Samplers for the task of ArmPointNav.\"\"\"\n\nimport json\nimport random\nfrom typing import List, Dict, Optional, Any"
},
{
"path": "allenact_plugins/manipulathor_plugin/manipulathor_tasks.py",
"chars": 20436,
"preview": "\"\"\"Task Definions for the task of ArmPointNav.\"\"\"\n\nimport copy\nfrom typing import Dict, Tuple, List, Any, Optional\n\nimpo"
},
{
"path": "allenact_plugins/manipulathor_plugin/manipulathor_utils.py",
"chars": 2391,
"preview": "import ai2thor\n\nfrom allenact_plugins.ithor_plugin.ithor_environment import IThorEnvironment\nfrom allenact_plugins.manip"
},
{
"path": "allenact_plugins/manipulathor_plugin/manipulathor_viz.py",
"chars": 15065,
"preview": "\"\"\"Utility functions and classes for visualization and logging.\"\"\"\n\nimport os\nfrom datetime import datetime\n\nimport cv2\n"
},
{
"path": "allenact_plugins/minigrid_plugin/__init__.py",
"chars": 252,
"preview": "from allenact.utils.system import ImportChecker\n\nwith ImportChecker(\n \"\\n\\nPlease install babyai with:\\n\\n\"\n \"pip "
},
{
"path": "allenact_plugins/minigrid_plugin/configs/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/minigrid_plugin/configs/minigrid_nomemory.py",
"chars": 953,
"preview": "\"\"\"Experiment Config for MiniGrid tutorial.\"\"\"\n\nimport gym\nimport torch.nn as nn\n\nfrom allenact.base_abstractions.sensor"
},
{
"path": "allenact_plugins/minigrid_plugin/data/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/minigrid_plugin/extra_environment.yml",
"chars": 92,
"preview": "dependencies:\n - patsy>=0.5.1\n - pip\n - pip:\n - gym-minigrid>=1.0.1\n - pickle5\n"
},
{
"path": "allenact_plugins/minigrid_plugin/extra_requirements.txt",
"chars": 41,
"preview": "patsy>=0.5.1\ngym-minigrid>=1.0.1\npickle5\n"
},
{
"path": "allenact_plugins/minigrid_plugin/minigrid_environments.py",
"chars": 6233,
"preview": "import copy\nfrom typing import Optional, Set\n\nimport numpy as np\nfrom gym import register\nfrom gym_minigrid.envs import "
},
{
"path": "allenact_plugins/minigrid_plugin/minigrid_models.py",
"chars": 8211,
"preview": "import abc\nfrom typing import Callable, Dict, Optional, Tuple, cast\n\nimport gym\nimport numpy as np\nimport torch\nfrom gym"
},
{
"path": "allenact_plugins/minigrid_plugin/minigrid_offpolicy.py",
"chars": 11622,
"preview": "import math\nimport queue\nimport random\nfrom collections import defaultdict\nfrom typing import Dict, Tuple, Any, cast, Li"
},
{
"path": "allenact_plugins/minigrid_plugin/minigrid_sensors.py",
"chars": 4313,
"preview": "from typing import Optional, Any, cast\n\nimport gym\nimport gym_minigrid.minigrid\nimport numpy as np\nimport torch\nfrom bab"
},
{
"path": "allenact_plugins/minigrid_plugin/minigrid_tasks.py",
"chars": 19332,
"preview": "import random\nfrom typing import Tuple, Any, List, Dict, Optional, Union, Callable, Sequence, cast\n\nimport gym\nimport ne"
},
{
"path": "allenact_plugins/minigrid_plugin/scripts/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/navigation_plugin/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/navigation_plugin/objectnav/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/navigation_plugin/objectnav/models.py",
"chars": 20972,
"preview": "\"\"\"Baseline models for use in the object navigation task.\n\nObject navigation is currently available as a Task in AI2-THO"
},
{
"path": "allenact_plugins/navigation_plugin/pointnav/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/navigation_plugin/pointnav/models.py",
"chars": 4928,
"preview": "\"\"\"Baseline models for use in the point navigation task.\n\nObject navigation is currently available as a Task in AI2-THOR"
},
{
"path": "allenact_plugins/robothor_plugin/__init__.py",
"chars": 214,
"preview": "from allenact.utils.system import ImportChecker\n\nwith ImportChecker(\n \"Cannot `import ai2thor`, please install `ai2th"
},
{
"path": "allenact_plugins/robothor_plugin/configs/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/robothor_plugin/extra_environment.yml",
"chars": 197,
"preview": "channels:\n - defaults\n - conda-forge\ndependencies:\n - ai2thor>=2.5.3\n - numba\n - pip\n - colour\n - packaging\n - p"
},
{
"path": "allenact_plugins/robothor_plugin/extra_requirements.txt",
"chars": 87,
"preview": "ai2thor>=2.5.3\nnumpy-quaternion\npyquaternion>=0.9.9\ncolour\nnumba\npackaging\npython-xlib\n"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_constants.py",
"chars": 149,
"preview": "MOVE_AHEAD = \"MoveAhead\"\nROTATE_LEFT = \"RotateLeft\"\nROTATE_RIGHT = \"RotateRight\"\nLOOK_DOWN = \"LookDown\"\nLOOK_UP = \"LookU"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_distributions.py",
"chars": 1147,
"preview": "from typing import Tuple\n\nimport torch\n\nfrom allenact.base_abstractions.distributions import CategoricalDistr, Distr\n\n\nc"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_environment.py",
"chars": 19352,
"preview": "import copy\nimport math\nimport random\nimport warnings\nfrom typing import Any, Optional, Dict, List, Union, Tuple, Collec"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_models.py",
"chars": 3760,
"preview": "from typing import Tuple, Optional\n\nimport gym\nimport torch\nfrom gym.spaces import Dict as SpaceDict\n\nfrom allenact.algo"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_preprocessors.py",
"chars": 8719,
"preview": "from collections import OrderedDict\nfrom typing import Dict, Any, Optional, List, cast\n\nimport gym\nimport numpy as np\nim"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_sensors.py",
"chars": 6829,
"preview": "from typing import Any, Tuple, Optional\n\nimport ai2thor.controller\nimport gym\nimport numpy as np\nimport quaternion # no"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_task_samplers.py",
"chars": 39305,
"preview": "import copy\nimport gzip\nimport json\nimport random\nfrom typing import List, Optional, Union, Dict, Any, cast, Tuple\n\nimpo"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_tasks.py",
"chars": 19770,
"preview": "import math\nfrom typing import Tuple, List, Dict, Any, Optional, Union, Sequence, cast\n\nimport gym\nimport numpy as np\n\nf"
},
{
"path": "allenact_plugins/robothor_plugin/robothor_viz.py",
"chars": 15438,
"preview": "import copy\nimport json\nimport math\nimport os\nfrom typing import Tuple, Sequence, Union, Dict, Optional, Any, cast, Gene"
},
{
"path": "allenact_plugins/robothor_plugin/scripts/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "allenact_plugins/robothor_plugin/scripts/make_objectnav_debug_dataset.py",
"chars": 2612,
"preview": "import gzip\nimport json\nimport os\nfrom typing import Sequence, Optional\n\nfrom allenact_plugins.robothor_plugin.robothor_"
},
{
"path": "allenact_plugins/robothor_plugin/scripts/make_pointnav_debug_dataset.py",
"chars": 646,
"preview": "import os\n\nfrom allenact_plugins.robothor_plugin.scripts.make_objectnav_debug_dataset import (\n create_debug_dataset_"
},
{
"path": "allenact_plugins/setup.py",
"chars": 4474,
"preview": "import glob\nimport os\nfrom pathlib import Path\n\nfrom setuptools import find_packages, setup\n\n\ndef parse_req_file(fname, "
},
{
"path": "conda/environment-10.1.yml",
"chars": 128,
"preview": "channels:\n - defaults\n - pytorch\ndependencies:\n - cudatoolkit=10.1\n - pytorch>=1.6.0,!=1.8.0\n - torchvision>=0.7.0,"
},
{
"path": "conda/environment-10.2.yml",
"chars": 128,
"preview": "channels:\n - defaults\n - pytorch\ndependencies:\n - cudatoolkit=10.2\n - pytorch>=1.6.0,!=1.8.0\n - torchvision>=0.7.0,"
},
{
"path": "conda/environment-11.1.yml",
"chars": 131,
"preview": "channels:\n - defaults\n - pytorch\n - nvidia\ndependencies:\n - cudatoolkit=11.1\n - pytorch>=1.6.0,!=1.8.0\n - torchvis"
},
{
"path": "conda/environment-9.2.yml",
"chars": 127,
"preview": "channels:\n - defaults\n - pytorch\ndependencies:\n - cudatoolkit=9.2\n - pytorch>=1.6.0,!=1.8.0\n - torchvision>=0.7.0,<"
},
{
"path": "conda/environment-base.yml",
"chars": 790,
"preview": "channels:\n - defaults\n - pytorch\n - conda-forge\ndependencies:\n - python=3.8\n - certifi\n - chardet=4.0.0\n - cloudp"
},
{
"path": "conda/environment-cpu.yml",
"chars": 119,
"preview": "channels:\n - defaults\n - pytorch\ndependencies:\n - cpuonly\n - pytorch>=1.6.0,!=1.8.0\n - torchvision>=0.7.0,<0.10.0\n"
},
{
"path": "conda/environment-dev.yml",
"chars": 303,
"preview": "channels:\n - defaults\n - conda-forge\ndependencies:\n - black>=24.2.0\n - docformatter>=1.3.1\n - gitpython\n - markdow"
},
{
"path": "constants.py",
"chars": 184,
"preview": "import os\nfrom pathlib import Path\n\nABS_PATH_OF_TOP_LEVEL_DIR = os.path.abspath(os.path.dirname(Path(__file__)))\nABS_PAT"
},
{
"path": "datasets/.gitignore",
"chars": 133,
"preview": "*\n!.gitignore\n!*.sh\n!.habitat_datasets_download_info.json\n!.habitat_downloader_helper.py\n!habitat/configs/debug_habitat_"
},
{
"path": "datasets/.habitat_datasets_download_info.json",
"chars": 1544,
"preview": "{\n \"pointnav-gibson-v1\": {\n \"link\": \"https://dl.fbaipublicfiles.com/habitat/data/datasets/pointnav/gibson/v1/p"
},
{
"path": "datasets/.habitat_downloader_helper.py",
"chars": 4026,
"preview": "import json\nimport os\nimport re\nimport shutil\nimport sys\nfrom pathlib import Path\nfrom urllib.request import urlopen\n\nfr"
},
{
"path": "datasets/download_habitat_datasets.sh",
"chars": 1124,
"preview": "#!/bin/bash\n\n# Move to the directory containing this file\ncd \"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" >/dev/null 2>&1 &"
},
{
"path": "datasets/download_navigation_datasets.sh",
"chars": 2377,
"preview": "#!/bin/bash\n\n# Move to the directory containing this file\ncd \"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" >/dev/null 2>&1 &"
}
]
// ... and 202 more files (download for full content)
About this extraction
This page contains the full source code of the allenai/allenact GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 402 files (2.0 MB), approximately 542.5k tokens, and a symbol index with 2386 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.