AI 101
\[ \sum_{i=1}^{n} w_i \times x_i \]
fiv belongs to.fiv1 in the fiveth position, and zeroes elsewhere.multi = np.array([
[-1/1, -1/1, -1/1, -1/1, 1/1, -1/1, -1/1, -1/1, -1/1],
[-1/2, -1/2, 1/2, -1/2, -1/2, -1/2, 1/2, -1/2, -1/2],
[-1/3, -1/3, 1/3, -1/3, 1/3, -1/3, 1/3, -1/3, -1/3],
[ 1/4, -1/4, 1/4, -1/4, -1/4, -1/4, 1/4, -1/4, 1/4],
[ 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5],
[ 0/6, 3/6, 0/6, 3/6, -6/6, 3/6, 0/6, 3/6, 0/6],
])[[-1. -1. -1. -1. 1. -1.
-1. -1. -1. ]
[-0.5 -0.5 0.5 -0.5 -0.5 -0.5
0.5 -0.5 -0.5 ]
[-0.33333333 -0.33333333 0.33333333 -0.33333333 0.33333333 -0.33333333
0.33333333 -0.33333333 -0.33333333]
[ 0.25 -0.25 0.25 -0.25 -0.25 -0.25
0.25 -0.25 0.25 ]
[ 0.2 -0.2 0.2 -0.2 0.2 -0.2
0.2 -0.2 0.2 ]
[ 0. 0.5 0. 0.5 -1. 0.5
0. 0.5 0. ]]
9) “sensory neurons”.| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
0 or 1 or perhaps True or False etc.| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
13 and 5 - where corners matter too.multi = np.array([
[-1/1, -1/1, -1/1, -1/1, 1/1, -1/1, -1/1, -1/1, -1/1],
[-1/2, -1/2, 1/2, -1/2, -1/2, -1/2, 1/2, -1/2, -1/2],
[-1/3, -1/3, 1/3, -1/3, 1/3, -1/3, 1/3, -1/3, -1/3],
[ 1/4, -1/4, 1/4, -1/4, -1/4, -1/4, 1/4, -1/4, 1/4],
[ 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5],
[ 0/6, 3/6, 0/6, 3/6, -6/6, 3/6, 0/6, 3/6, 0/6],
])multi = np.array([
[-1/1, -1/1, -1/1, -1/1, 1/1, -1/1, -1/1, -1/1, -1/1],
[-1/2, -1/2, 1/2, -1/2, -1/2, -1/2, 1/2, -1/2, -1/2],
[-1/3, -1/3, 1/3, -1/3, 1/3, -1/3, 1/3, -1/3, -1/3],
[ 1/4, -1/4, 1/4, -1/4, -1/4, -1/4, 1/4, -1/4, 1/4],
[ 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5],
[ 0/6, 3/6, 0/6, 3/6, -6/6, 3/6, 0/6, 3/6, 0/6],
])multi = np.array([
[-1/1, -1/1, -1/1, -1/1, 1/1, -1/1, -1/1, -1/1, -1/1],
[-1/2, -1/2, 1/2, -1/2, -1/2, -1/2, 1/2, -1/2, -1/2],
[-1/3, -1/3, 1/3, -1/3, 1/3, -1/3, 1/3, -1/3, -1/3],
[ 1/4, -1/4, 1/4, -1/4, -1/4, -1/4, 1/4, -1/4, 1/4],
[ 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5],
[ 0/6, 3/6, 0/6, 3/6, -6/6, 3/6, 0/6, 3/6, 0/6],
])layer = np.array([
Neuron([-1/1, -1/1, -1/1, -1/1, 1/1, -1/1, -1/1, -1/1, -1/1], 1),
Neuron([-1/2, -1/2, 1/2, -1/2, -1/2, -1/2, 1/2, -1/2, -1/2], 1),
Neuron([-1/3, -1/3, 1/3, -1/3, 1/3, -1/3, 1/3, -1/3, -1/3], 1),
Neuron([ 1/4, -1/4, 1/4, -1/4, -1/4, -1/4, 1/4, -1/4, 1/4], 1),
Neuron([ 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5, -1/5, 1/5], 1),
Neuron([ 0/6, 3/6, 0/6, 3/6, -6/6, 3/6, 0/6, 3/6, 0/6], 1),
])[Neuron[-1. -1. -1. -1. 1. -1. -1. -1. -1.]
Neuron[-0.5 -0.5 0.5 -0.5 -0.5 -0.5 0.5 -0.5 -0.5]
Neuron[-0.33333333 -0.33333333 0.33333333 -0.33333333 0.33333333 -0.33333333
0.33333333 -0.33333333 -0.33333333]
Neuron[ 0.25 -0.25 0.25 -0.25 -0.25 -0.25 0.25 -0.25 0.25]
Neuron[ 0.2 -0.2 0.2 -0.2 0.2 -0.2 0.2 -0.2 0.2]
Neuron[ 0. 0.5 0. 0.5 -1. 0.5 0. 0.5 0. ]]
np.random.rand and tell it what shape we want.0 and 1 by default.[[0.84782583 0.99754661 0.37144545 0.35951125 0.51952776 0.91167008
0.18851714 0.60068732 0.83017473]
[0.38500627 0.78754125 0.17222118 0.12132224 0.74023843 0.76830758
0.082289 0.85673835 0.52457145]
[0.44879353 0.07166859 0.90172392 0.01826042 0.35074145 0.58281399
0.41051414 0.48591482 0.7055296 ]
[0.14371779 0.49439823 0.98417158 0.75418984 0.89979416 0.51440135
0.06060489 0.86794552 0.32507273]
[0.03575555 0.59445296 0.59595104 0.6717415 0.79543474 0.08331623
0.17968061 0.95994688 0.0408776 ]
[0.59737745 0.46468292 0.68213292 0.2598974 0.18333893 0.2499059
0.12540588 0.53740209 0.0211946 ]]
.1 or something..1 or something.learn
self since it’s a function inside of a neuron..learnlearnlearneach, how much “each” weight should change, by3.[0.55717766 0.39847885 0.24116268 0.65048909 0.73394148 0.97247015
0.39872539 0.8811111 0.38007921]
delta = bias - sum(is_two * thr)
each = 1.1 * delta / sum(thr)
update = each * np.array(thr)
is_two = is_two + update
print(is_two)[0.55717766 0.39847885 1.18357492 0.65048909 0.37829217 0.97247015
1.34113764 0.8811111 0.38007921]
class Neuron:
def __init__(self, weights=np.random.rand(9), bias=1):
self.weights = np.array(weights)
self.bias = bias
def __repr__(self):
return "Neuron" + str(self.weights)
def __mul__(self, other):
return int(np.sum(self.weights * other) >= self.bias)
def learn(self, perceived, answer):
if answer == self * perceived:
return
delta = self.bias - np.sum(self.weights * perceived)
each = 1.1 * delta / sum(perceived)
update = each * np.array(perceived)
self.weights = self.weights + update Neuron[0.34059675 0.3768527 0.33380208 0.86193088 0.59068583 0.95907908
0.84126294 0.84504323 0.21381956]
[0 0 0 0 1 0 0 0 0] 0 0
[0 0 1 0 0 0 1 0 0] 0 0
[0 0 1 0 1 0 1 0 0] 0 0
[1 0 1 0 0 0 1 0 1] 0 0
[1 0 1 0 1 0 1 0 1] 1 0
[1 0 1 1 0 1 1 0 1] 0 0
Neuron[ 0.18758228 0.3768527 -0.1256639 0.53021633 0.59127919 0.62736452
0.38179695 0.84504323 0.06080508]
Neuron[ 1.26543523e-01 3.76852701e-01 -1.86702658e-01 3.21210453e-01
7.39246313e-01 4.18358648e-01 3.20758197e-01 8.45043230e-01
-2.33670892e-04]
class Neuron:
def __init__(self, weights=np.random.rand(9), bias=1):
self.weights = np.array(weights)
self.bias = bias
def __repr__(self):
return "Neuron" + str(self.weights)
def __mul__(self, other):
return int(np.sum(self.weights * other) >= self.bias)
def learn(self, perceived, answer):
if answer == self * perceived:
temp = perceived + .5
temp /= sum(perceived)
self.weights *= temp
else:
delta = self.bias - np.sum(self.weights * perceived)
each = delta / sum(perceived)
update = each * np.array(perceived)
self.weights = self.weights + update