In [29]:
import numpy as np
In [30]:
# Defining the sigmoid function for activations
def sigmoid(x):
return 1/(1+np.exp(-x))
In [31]:
# Network size
N_input = 4
N_hidden = 3
N_output = 2
In [32]:
np.random.seed(42)
In [33]:
# Make some fake data
X = np.random.randn(4)
print(X)
In [34]:
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))
print(weights_input_to_hidden)
print(weights_hidden_to_output)
In [35]:
# TODO: Make a forward pass through the network
hidden_layer_in = np.dot(X, weights_input_to_hidden)
print('Hidden-layer Input:')
print(hidden_layer_in)
In [36]:
hidden_layer_out = sigmoid(hidden_layer_in)
print('Hidden-layer Output:')
print(hidden_layer_out)
In [37]:
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)
In [ ]: