-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintro_deep_learning1.py
More file actions
43 lines (31 loc) · 1.32 KB
/
intro_deep_learning1.py
File metadata and controls
43 lines (31 loc) · 1.32 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
import numpy as np
from numpy import array
input_data=array([3,5])
weights={'node_0_0': array([2, 4]),
'node_0_1': array([ 4, -5]),
'node_1_0': array([-1, 2]),
'node_1_1': array([1, 2]),
'output': array([2, 7])}
def predict_with_network(input_data):
# Calculate node 0 in the first hidden layer
node_0_0_input = (input_data * weights["node_0_0"]).sum()
node_0_0_output = relu(node_0_0_input)
# Calculate node 1 in the first hidden layer
node_0_1_input = (input_data * weights["node_0_1"]).sum()
node_0_1_output = relu(node_0_1_input)
# Put node values into array: hidden_0_outputs
hidden_0_outputs = np.array([node_0_0_output, node_0_1_output])
# Calculate node 0 in the second hidden layer
node_1_0_input = (hidden_0_outputs*weights["node_1_0"]).sum()
node_1_0_output = relu(node_1_0_input)
# Calculate node 1 in the second hidden layer
node_1_1_input = (hidden_0_outputs*weights["node_1_1"]).sum()
node_1_1_output = relu(node_1_1_input)
# Put node values into array: hidden_1_outputs
hidden_1_outputs = np.array([node_1_0_output, node_1_1_output])
# Calculate model output: model_output
model_output = (hidden_1_outputs*weights["output"]).sum()
# Return model_output
return(model_output)
output = predict_with_network(input_data)
print(output)