Giter Club home page Giter Club logo

encode-attend-navigate-pytorch's Introduction

encode-attend-navigate-pytorch

Pytorch implementation of encode-attend-navigate, a Deep Reinforcement Learning based TSP solver.

Get started

Run on Colab

You can leverage the free GPU on Colab to train this model. Just run this notebook : Open In Colab

Run locally

Clone the repository :

git clone https://github.com/astariul/encode-attend-navigate-pytorch.git
cd encode-attend-navigate-pytorch

Install dependencies :

pip install -r requirements.txt

Run the code :

python main.py

You can specify your own configuration file :

python main.py config=my_conf.yaml

Or directly modify parameters from the command line :

python main.py lr=0.002 max_len=100 batch_size=64

Expected results

I ran the code with the following command line :

python main.py enc_stacks=1 lr=0.0002 p_dropout=0.1

On Colab, with a Tesla T4 GPU, it tooks 1h 46m for the training to complete.

Here is the training curves :


After training, here is a few example of path generated :

Implementation

This code is a direct translation of the official TF 1.x implementation, by @MichelDeudon.

Please refer to their README for additional details.


To ensure the Pytorch implementation produces the same results as the original implementation, I compared the outputs of each layer given the same inputs and check if they are the same.

You can find (and run) these tests on this Colab notebook : Open In Colab

encode-attend-navigate-pytorch's People

Contributors

astariul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

encode-attend-navigate-pytorch's Issues

linear VS convolution

In the original version, they have used conv1d layer but you have used linear layers in those places. Will both do the same kind of operation?

๐Ÿ› Critic not detached from policy loss

The policy loss uses the critic (to compute the TD error) :

loss1 = ((reward - critique) * log_probs).mean()


But the critic should not receive any backpropagation from the policy loss. Gradients should be stopped. In the original implementation, they do :

self.loss = tf.reduce_mean(tf.stop_gradient(self.reward-self.predictions)*self.log_prob, axis=0)

(Notice the tf.stop_gradient() function)

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.