added a brain, need to listen to it

This commit is contained in:
2019-10-21 15:19:50 +02:00
parent 06c54f50fa
commit c31a338957
7 changed files with 253 additions and 162 deletions

26
brain.py Normal file
View File

@@ -0,0 +1,26 @@
import numpy as np
class Neural_Network(object):
# inspired from https://enlight.nyc/projects/neural-network/
def __init__(self):
#parameters
self.inputSize = 3
self.outputSize = 2
self.hiddenSize = 3
#weights
self.W1 = np.random.randn(self.inputSize, self.hiddenSize) # weights from input to hidden layer
self.W2 = np.random.randn(self.hiddenSize, self.outputSize) # weights from hidden to output layer
def predict(self, X):
#forward propagation through our network
self.z = np.dot(X, self.W1) # dot product of X (input) and first set of 3x2 weights
self.z2 = self.sigmoid(self.z) # activation function
self.z3 = np.dot(self.z2, self.W2) # dot product of hidden layer (z2) and second set of 3x1 weights
o = self.sigmoid(self.z3) # final activation function
return o
def sigmoid(self, s):
# activation function
return 1/(1+np.exp(-s)) -0.5