Coder Social home page Coder Social logo

ensemblequantilenetworks's Introduction

Ensemble Quantile Networks: Uncertainty-Aware Reinforcement Learning with Applications in Autonomous Driving

This repo contains the code that was used in the paper Ensemble Quantile Networks: Uncertainty-Aware Reinforcement Learning with Applications in Autonomous Driving. If this code is used, please cite the paper and the repo.

Animations of the trained agents are shown below, followed by a brief instruction on how to use the code.


Videos

This section shows how the trained agents behave in a few test episodes with high aleatoric and epistemic uncertainty, respectively. The animations correspond to Figure 4, 7, and 9 in the paper.

The ego vehicle is the truck that is approaching the intersecion from the south, and the color of the ego vehicle depends on its current decision: green - go, yellow - cruise, red - stop, blue - safety policy. A description of the precise interpretation of the different actions is provided in the paper. Note that when the ego vehicle is standing still, the actions stop and cruise have the same effect, whereas at the maximum speed 15 m/s, the actions go and cruise have the same effect.

The gray areas represent occluding objects, such as buildings. The occluded vehicles are also displayed in gray, whereas observed vehicles are shown in color. The colors of the surrounding vehicles depend on their current speed, ranging from yellow to red, which corresponds to the interval 0 to 15 m/s.

The animations are also available as mp4 files in videos/, if you would like to pause or step through the animations. If you want the gif:s below to start at the same time, just reload the page in your browser.


Fig. 4, aleatoric uncertainty

Both agents follow the same policy until time step 11. At this time, the risk-sensitive agent chooses to slow down to cross the intersection at a low speed, whereas the risk-neutral agent crosses the intersection at full speed, whích in this case causes a collision. Note the high estimated aleatoric uncertainty of the chosen actions for the risk-neutral agent from time step 11.

IQN, :

IQN, :


Fig. 7, aleatoric uncertainty

In this situation, the aleatoric uncertainty arises from the unknown intention of the vehicle that is approaching the intersection from the west, see the paper for more details. The agent that does not take aleatoric uncertainty into account selects the action go at time step 37, which causes a collision. Note that the estimated aleatoric uncertainty of this action is high. Therefore, the agent that restricts the allowed aleatoric uncertainty instead applies the backup policy at time step 37 and can thereby avoid the collision.

IQN, :

IQN, :


Fig. 9, epistemic uncertainty

In this situation, there is a high epistemic uncertainty due to the high speed of the vehicles that are approaching from the east. During the training phase, the agent was exposed to vehicles with speeds up to 15 m/s, whereas the vehicle that is involved in the collision is driving at 23 m/s. Note the high epistemic uncertainty at time step 1. The second agent therefore applies the backup policy and avoids the collision. Vehicles that are driving faster than 15 m/s are displayed in different shades of purple.

RPF, :

RPF, :


Source code

Prerequisites

Python and Simulation of Urban Mobility (SUMO), version 1.8 (something have changed in the interface in later versions, and I have not had the time to update the code).

Install SUMO from source (tested for ubuntu 18.04):

apt-get update
apt-get install -y git cmake python3.7 python3-pip g++ libxerces-c-dev libfox-1.6-dev libgdal-dev libproj-dev libgl2ps-dev graphviz
git clone --depth 1 --branch v1_8_0 https://github.com/eclipse/sumo
mkdir sumo/build/cmake-build
cd sumo/build/cmake-build
cmake ../..
make -j$(nproc)
make install
cd ../../..
rm -r sumo
export SUMO_HOME="/usr/local/share/sumo"

Install dependencies:

pip3 install -r requirements.txt

Docker

Using Docker makes it even easier to get started. From the top folder, simply build with Dockerfile:

docker build -t <name> -f Dockerfile .

Usage

The code is relatively well documented. The following steps help to get you started.

Training process

To start the training of the agent, from src/, run:

python3 train_agent.py <log_name>

The performance of the agent is regularly tested on a set of test episodes. Logs are saved in logs/, where among other things the following are saved:

  • Rewards and number of steps of the test episodes
  • Weights of the neural networks for the test episodes
  • Tensorboard logs for both the training and test episodes.

The performance of the agent can be followed in tensorboard during the training process.

Parameters

The parameters of the agent are set in parameters.py and the parameters of the simulation environment are set in parameters_intersection.py.

Visualize trained agent

The behavior of the trained agent can be observed in SUMO's GUI, both for the test episodes and for the special cases that are mentioned in the paper.

In run_trained_agent.py, set filepath and agent_name to the agent you would like to test. Additional visualization options are available, see the description in the file. Then, from src/, run:

python3 run_trained_agent.py

An example of the output is shown below.

Tests

A number of tests are included to make sure that the code is working and all dependencies are fulfilled. From tests/, run:

python3 -m unittest discover .

It will take around 30 minutes to run all tests. If successful, the system will provide the following output when the tests are done (the exact time will of course vary):

----------------------------------------------------------------------
Ran 81 tests in 1774.524s

OK
Error: tcpip::Socket::recvAndCheck @ recv: peer shutdown
Quitting (on error).

Note that if you receive this output, everything is working fine. The "error" above does not refer to an error in the tests, it's just an output from when disconnecting from SUMO.

License

This code is released under the MIT license, see LICENSE.md for details.

Contact

Just send an email if you have any questions, [email protected] or [email protected].

ensemblequantilenetworks's People

Contributors

carljohanhoel avatar

Stargazers

feitianyang avatar Lei He avatar  avatar Topwoo avatar swb19 avatar  avatar Jeffrey X.L. Chan avatar  avatar Jason avatar  avatar Zhao Junwu avatar wangze avatar Min Seong Kim avatar paller avatar Simon Chauvin avatar TzuRen avatar

Watchers

James Cloos avatar  avatar Jeffrey X.L. Chan avatar

ensemblequantilenetworks's Issues

source code update missed?

Hi, guys, I came here from the paper EQN, and was very interested in your works, but found an empty repo here, when will you guys update it ? : )

Questions about the IQN environment

Dear Carl-Johan,
I'm very interested in your research, but there is a problem when running this IQN environment.
Whenever the current EPOCH ends and before the next EPOCH starts, the running environment will report the following error (the vehicle cannot be identified, and it is repeated for 5 times. I think all the vehicles involved in the current EPOCH will be reported as errors)

Error: Answered with error to command 0xa4: Vehicle 'veh00' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh00' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh00' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh00' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh00' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh01' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh01' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh01' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh01' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh01' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh02' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh02' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh02' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh02' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh02' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh03' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh03' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh03' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh03' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh03' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh04' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh04' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh04' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh04' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh04' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh05' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh05' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh05' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh05' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh05' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh06' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh06' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh06' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh06' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh06' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh07' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh07' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh07' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh07' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh07' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh08' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh08' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh08' is not known.
Error: Answered with error to command 0xa4: Vehicle 'veh08' is not known.
......
1

Could you tell me where the configuration is wrong?

Looking forward to your reply

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.