-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremake.py
More file actions
45 lines (41 loc) · 1.52 KB
/
remake.py
File metadata and controls
45 lines (41 loc) · 1.52 KB
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
from random import random
#[input, [# hidden layer:[neuron:[weight, bias]]], output]
#0 = weight, 1= bias
def initialize_neural_network(n_input =0,n_hidden_layers =[0,0,0], n_output =0):
neural_network = []
hidden_layers = []
for i in range(0,len(n_hidden_layers)):
layer = []
if i == 0:
for j in range(0,n_hidden_layers[i]):
neuron = []
for k in range(0,n_input):
connection ={}
connection['Weight'] =random()
connection['Bias'] = random()
neuron.append(connection)
layer.append(neuron)
else:
for j in range(0,n_hidden_layers[i]):
neuron = []
for k in range(0,n_hidden_layers[i-1]):
connection ={}
connection['Weight'] =random()
connection['Bias'] = random()
neuron.append(connection)
layer.append(neuron)
hidden_layers.append(layer)
output_layer = []
for i in range(0,n_output):
neuron = []
for j in range(0,n_hidden_layers[-1]):
connection = {}
connection['Weight'] =random()
connection['Bias'] = random()
neuron.append(connection)
output_layer.append(neuron)
neural_network.append(hidden_layers)
neural_network.append(output_layer)
return neural_network
neural_network = initialize_neural_network(2,[2,2],1)
print(neural_network)