Skip to content

Instantly share code, notes, and snippets.

@arthurazs
Created July 22, 2018 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arthurazs/4c170bee9ce1c5ea301819abd9d14ed5 to your computer and use it in GitHub Desktop.
Save arthurazs/4c170bee9ce1c5ea301819abd9d14ed5 to your computer and use it in GitHub Desktop.
Simple deep learning example (node + weight + relu)
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)
@arthurazs
Copy link
Author

arthurazs commented Jul 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment