Skip to content
Advertisement

Knight’s Tour using a Neural Network

I was looking at the knights tour problem and decided to have a go at implementing it in python using a neural network to find solutions.

The general explanation of the method can be found on Wikipedia

While I think I have implemented it correctly (I can’t see anything else that is wrong), it doesn’t work, it updates a few links, removing the edges where the connecting vertex has a degree more than two, but it doesn’t converge on the solution.

I was wondering if anyone had any ideas on what I have implemented incorrectly (Sorry about the horrible code).

EDIT
Working code can be found at GitHub https://github.com/Yacoby/KnightsTour

Advertisement

Answer

You can’t update the neurons in place. Since U[t+1] depends on U[t] and V[t], if you have already updated V the calculation for U will be wrong

I think you should split the update into two phases update_state and update_output, so all the U are updated and then all the V

    for n in neurons:
        n.update_state()
    for n in neurons:
        n.update_output()
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement