Code Monkey home page Code Monkey logo

spatial-reasoning's Introduction

Spatial Reasoning

Code and data to reproduce the experiments in Representation Learning for Grounded Spatial Reasoning.

Installation

Get PyTorch and pip install -r requirements

./download_data.sh to get the annotated map data and sprites to make new maps.

Note: There were a few breaking changes in the latest PyTorch release that affected this repo. Make sure you are using v0.2.0+ (torch.__version__ to check)

Data

We have collected human annotations of 3308 goals in 10x10 maps, specified by referencing one or more of 12 object types placed randomly in the world. To load up to max_train train maps and max_val val maps with mode = [ local | global ] instructions and annotations = [ human | synthetic ] descriptions, run:

>>> import data
>>> train_data, val_data = data.load(mode, annotations, max_train, max_val)
>>> layouts, objects, rewards, terminal, instructions, values, goals = train_data

where layouts and objects are arrays with item identifiers, rewards and terminal are arrays that can be used to construct an MDP, instructions are a list of text descriptions of the coordinates in goals, and values has the ground truth state values from Value Iteration.

To generate more maps (with synthetic annotations):

$ python generate_worlds.py --mode [ local | global ] --save_path data/example_worlds/ --vis_path data/example_env/

which will save pickle files that can be loaded with data.load() in data/example_worlds/ and visualizations in data/example_env/. Visualizations of a few of the maps downloaded to data/local/ are in data/local_sprites/.

Visualizations of randomly generated worlds

Training

To train the model with reinforcement learning:

$ python reinforcement.py --annotations [ human | synthetic ] --mode [ local | global ] --save_path logs/trial/

This will save the model, pickle files with the predictions, and visualizations to logs/trial/.

To train the models in a supervised manner for the representation analysis, run python representation.py with the same arguments as above.

Predicted values for two maps with two instructions each. In the first map, the instructions share no objects but refer to the same location. In the second map, the instructions refer to different locations.

Acknowledgments

A huge thank you to Daniel Fried and Jacob Andreas for providing a copy of the human annotations when the original Dropbox link was purged.

spatial-reasoning's People

Contributors

jannerm avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.