Skip to content

Instantly share code, notes, and snippets.

@danieljoserodriguez
Last active August 21, 2019 05:41
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 danieljoserodriguez/c1ea151c05cc0e9307b7c5a63ead19c3 to your computer and use it in GitHub Desktop.
Save danieljoserodriguez/c1ea151c05cc0e9307b7c5a63ead19c3 to your computer and use it in GitHub Desktop.
Neural Network - Python - Simplest Multiple Neurons and Layers - Feed Forward
# 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
# multiple inputs and layers neural network
import numpy as np
# neuron layers
hidden_neuron_weights = np.array([0.1, 0.2, 0]) # 3 inputs, 3 outputs
output_neuron_weights = np.array([0.2, 0, 0.1]) # 3 inputs, 3 outputs
# output_neuron_weights = np.array([0.2, 0.1]) # 3 inputs, 2 outputs
# output_neuron_weights = np.array([0.2]) # 3 inputs, 1 output
# sample data
test_scores = [.99, .75]
hours_studied = [.5, .3]
hours_slept = [.7, .4]
sample_input = [test_scores[0], hours_studied[0], hours_slept[0]]
# feed forward prediction
hidden_prediction = np.dot(sample_input, hidden_neuron_weights)
output_prediction = np.dot(hidden_prediction, output_neuron_weights)
print(output_prediction)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment