简体   繁体   中英

How to create basic neural network in Python/Pygame?

I am trying to understand how to create a basic, simple neural network in Python/Pygame. I have read this tutorial and my aim is to create a program similar to the program that is described in "AI junkie". Although this tutorial is pretty simple. I still don't fully get it, and I am not sure about the connection between the output of the neurons to the movement of the tanks. Where can I find a simple, basic code of a program like this written in pygame/python, to try improving my understanding of the implementation of the algorithm?

Thanking you in anticipation!

Check @Nathan's Python code in this post. It's pretty clean and also good to take as a start point.

If you want logistic activation:

def logistic(x):
    return 1/(1+math.exp(-x))

# derivative of logistic
def dlogistic(y):
    return y*(1-y)

The default activation function is tanh in the original code.

It's quite straightforward to construct a network and start training:

# create a network with 5 inputs, 20 hiddens, and one output nodes
n = NN(5, 20, 1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM