pull/1/head
E. Almqvist 4 years ago
parent baeede78f4
commit c1de21eaad
  1. 3
      rgbAI/lib/func.py
  2. 2
      rgbAI/main.py

@ -98,9 +98,8 @@ class AIlib:
# i.e. : W' = W - lr * gradient (respect to W in layer i) = W - lr*[ dC / dW[i] ... ] # i.e. : W' = W - lr * gradient (respect to W in layer i) = W - lr*[ dC / dW[i] ... ]
# So if we change all the weights with i.e. 0.01 = theta, then we can derive the gradient with math and stuff # So if we change all the weights with i.e. 0.01 = theta, then we can derive the gradient with math and stuff
inp = np.asarray(np.random.rand( 1, inputNum ))[0] # create a random learning sample
while( not curCost or curCost > targetCost ): # targetCost is the target for the cost function while( not curCost or curCost > targetCost ): # targetCost is the target for the cost function
inp = np.asarray(np.random.rand( 1, inputNum ))[0] # create a random learning sample
maxLen = len(obj.bias) maxLen = len(obj.bias)
grads, res, curCost = AIlib.gradient( inp, obj, theta, maxLen - 1 ) grads, res, curCost = AIlib.gradient( inp, obj, theta, maxLen - 1 )
obj = AIlib.mutateProps( obj, maxLen, grads ) # mutate the props for next round obj = AIlib.mutateProps( obj, maxLen, grads ) # mutate the props for next round

@ -29,7 +29,7 @@ class rgb(object):
return cost return cost
def learn( self ): def learn( self ):
ai.learn( 3, 0.01, self, 0.001 ) ai.learn( 3, 0.0001, self, 0.001 )
def think( self, inp:np.array ): def think( self, inp:np.array ):
print("\n-Input-") print("\n-Input-")

Loading…
Cancel
Save