-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopulation.py
More file actions
34 lines (23 loc) · 829 Bytes
/
population.py
File metadata and controls
34 lines (23 loc) · 829 Bytes
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
import numpy as np
inputLayerSize = 4
hiddenLayer_1_Size = 4
hiddenLayer_2_Size = 2
outputLayerSize = 1
class Individue:
def __init__(self):
self.fitness = 0
W1 = np.random.randn(inputLayerSize, hiddenLayer_1_Size) # np.random.uniform(1.1, 3.1) *
W2 = np.random.randn(hiddenLayer_1_Size, hiddenLayer_2_Size)
W3 = np.random.randn(hiddenLayer_2_Size, outputLayerSize)
self.weights = [W1, W2, W3]
class Population:
def __init__(self, size):
self.population = []
for i in range(size):
self.population.append(Individue())
def get(self):
return self.population
def set(self, population):
self.population = population
def add(self, individue):
self.population.append(individue)