Created
July 13, 2020 03:36
-
-
Save BlackFoxgamingstudio/db2cfb3ad677d497340bc66a4f92e189 to your computer and use it in GitHub Desktop.
Implementing the hidden layer
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 | |
def sigmoid(x): | |
""" | |
Calculate sigmoid | |
""" | |
return 1/(1+np.exp(-x)) | |
# Network size | |
N_input = 4 | |
N_hidden = 3 | |
N_output = 2 | |
np.random.seed(42) | |
# Make some fake data | |
X = np.random.randn(4) | |
weights_input_to_hidden = np.random.normal(0, scale=0.1, size=(N_input, N_hidden)) | |
weights_hidden_to_output = np.random.normal(0, scale=0.1, size=(N_hidden, N_output)) | |
# TODO: Make a forward pass through the network | |
hidden_layer_in = None | |
hidden_layer_out = None | |
print('Hidden-layer Output:') | |
print(hidden_layer_out) | |
output_layer_in = None | |
output_layer_out = None | |
print('Output-layer Output:') | |
print(output_layer_out) |
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 | |
def sigmoid(x): | |
""" | |
Calculate sigmoid | |
""" | |
return 1/(1+np.exp(-x)) | |
# Network size | |
N_input = 4 | |
N_hidden = 3 | |
N_output = 2 | |
np.random.seed(42) | |
# Make some fake data | |
X = np.random.randn(4) | |
weights_input_to_hidden = np.random.normal(0, scale=0.1, size=(N_input, N_hidden)) | |
weights_hidden_to_output = np.random.normal(0, scale=0.1, size=(N_hidden, N_output)) | |
# TODO: Make a forward pass through the network | |
hidden_layer_in = np.dot(X, weights_input_to_hidden) | |
hidden_layer_out = sigmoid(hidden_layer_in) | |
print('Hidden-layer Output:') | |
print(hidden_layer_out) | |
output_layer_in = np.dot(hidden_layer_out, weights_hidden_to_output) | |
output_layer_out = sigmoid(output_layer_in) | |
print('Output-layer Output:') | |
print(output_layer_out) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment