Imporvements to the AIs init function

pull/1/head
E. Almqvist 4 years ago
parent 8d955c5e7a
commit 63ae5b65ca
  1. BIN
      lib/__pycache__/func.cpython-38.pyc
  2. 7
      lib/func.py
  3. 22
      main.py

@ -1,10 +1,11 @@
import numpy as np
def sigmoid(x):
class AIlib:
def sigmoid(x):
return 1/(1 + np.exp(-x))
def correctFunc(rgb): # generates the correct answer for the AI
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 ):
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)

@ -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()

Loading…
Cancel
Save