1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| import numpy as np
class blackbrain():
def __init__(self):
self.synapses = np.random.rand(4, 4)
self.buffer = np.zeros(4)
self.map = np.array([1.0, 1, 0, 0])
self.synapses2 = np.random.rand(4, 4)
self.buffer2 = np.zeros(4)
self.map2 = np.array([1.0, 0, 0, 1])
self.average = 0
def sommation(self):
for i in range(4):
self.buffer += self.synapses[i]
def activation(self):
#voir les 2 plus grands
for i in range(4):
if self.buffer[i] < 3:
self.buffer[i] = 0
self.map[i] = 0
else:
self.map[i] = 1
def inhibition(self):
for i in range(4):
for j in range(4):
self.buffer[j] -= self.buffer[i] * 0.1
def correctionSyn(self):
for i in range(4):
if self.map[i]:
self.synapses[i] *=1.1
else:
self.synapses[i]*+0.9
def liaison(self):
self.buffer = self.map2 *5
def tour(self):
self.sommation()
self.liaison()
self.inhibition()
self.activation()
self.correctionSyn()
def print(self):
print(self.buffer, '\n\n\n', self.map) |
Partager