diff --git a/lib/__pycache__/func.cpython-38.pyc b/lib/__pycache__/func.cpython-38.pyc index f29ca80..bee87e9 100644 Binary files a/lib/__pycache__/func.cpython-38.pyc and b/lib/__pycache__/func.cpython-38.pyc differ diff --git a/lib/func.py b/lib/func.py index 3d1c1d2..4e3f7e0 100644 --- a/lib/func.py +++ b/lib/func.py @@ -1,10 +1,11 @@ import numpy as np -def sigmoid(x): - return 1/(1 + np.exp(-x)) +class AIlib: + def sigmoid(x): + return 1/(1 + np.exp(-x)) -def correctFunc(rgb): # generates the correct answer for the AI - return ( rgb[2], rgb[1], rgb[0] ) # basically invert the rgb values + def correctFunc(rgb): # generates the correct answer for the AI + return ( rgb[2], rgb[1], rgb[0] ) # basically invert the rgb values -def genRandomMatrix( x:int, y:int ): - return np.random.rand(x, y) + def genRandomMatrix( x:int, y:int ): # generate a matrix with x, y dimensions with random values from 0-1 in it + return np.random.rand(x, y) diff --git a/main.py b/main.py index f20d8f0..379363c 100755 --- a/main.py +++ b/main.py @@ -1,14 +1,26 @@ #!/usr/bin/env python -from lib.func import * +from lib.func import AIlib as ai class rgb(object): - def __init__(self): - self.weights = 1 + def __init__(self, loadedWeights = None, loadedBias = None): - def think(self, inputMatrix): - print("thonk: " + str( sigmoid(self.weights) )) + if( not loadedWeights or not loadedBias ): + self.weights = [ ai.genRandomMatrix(3, 4), ai.genRandomMatrix(4, 4), ai.genRandomMatrix(4, 3) ] # array of matrices of weights + # 3 input neurons -> 4 hidden neurons -> 4 hidden neurons -> 3 output neurons + + # Will be needing biases too + self.bias = [ ai.genRandomMatrix(1, 4), ai.genRandomMatrix(1, 4), ai.genRandomMatrix(1, 3) ] + # This doesn't look very good, but it works so... + # This is all we need + else: # if we want to load our progress from before then this would do it + print("Loading neural net...") + self.weights = loadedWeights + self.bias = loadedBias + def think(self, inputMatrix): + print(self.weights) + print(self.bias) def init(): # init func bot = rgb()