Created
July 22, 2018 02:16
-
-
Save arthurazs/4c170bee9ce1c5ea301819abd9d14ed5 to your computer and use it in GitHub Desktop.
Simple deep learning example (node + weight + relu)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sys import argv | |
def relu(input_value): | |
output_value = max(0, input_value) | |
return output_value | |
children = int(argv[1]) | |
accounts = int(argv[2]) | |
input_data = np.array([children, accounts]) | |
weights = { | |
'node_0': np.array([2, 4]), | |
'node_1': np.array([4, -5]), | |
'output': np.array([2, 7]) | |
} | |
node_0_input = (input_data * weights['node_0']).sum() | |
node_1_input = (input_data * weights['node_1']).sum() | |
node_0_output = relu(node_0_input) | |
node_1_output = relu(node_1_input) | |
hidden_layer_values = np.array([node_0_output, node_1_output]) | |
input_final_layer = (hidden_layer_values * weights['output']).sum() | |
output = relu(input_final_layer) | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
DataCamp