Last active
August 21, 2019 05:41
-
-
Save danieljoserodriguez/7f55d7299d8585c5c193d74b8ab2d747 to your computer and use it in GitHub Desktop.
Neural Network - Python - Simplest Multiple Neurons
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
# Daniel J. Rodriguez | |
# https://github.com/danieljoserodriguez | |
# This Gist is for information purposes only to demonstrate how to perform the task at hand. | |
# I do not advise using this in a production environment - rather - for learning on your own. | |
# simple multiple inputs neural network | |
######################################################################## | |
# just python - no extra libraries | |
def sum_weights(inputs, weights): | |
# assume input and weight len is equal | |
result = 0 | |
for index in range(len(inputs)): | |
result += inputs[index] * weights[index] | |
return result | |
neuron_weights = [0.1, 0.2, 0] | |
test_scores = [.99, .75] | |
hours_studied = [.5, .3] | |
hours_slept = [.7, .4] | |
sample_input = [test_scores[0], hours_studied[0], hours_slept[0]] | |
prediction = sum_weights(sample_input, neuron_weights) | |
print(prediction) | |
######################################################################## | |
# same as above but using numpy | |
import numpy as np | |
neuron_weights = [0.1, 0.2, 0] | |
test_scores = [.99, .75] | |
hours_studied = [.5, .3] | |
hours_slept = [.7, .4] | |
sample_input = [test_scores[0], hours_studied[0], hours_slept[0]] | |
prediction = np.dot(sample_input, neuron_weights) | |
print(prediction) | |
######################################################################## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment