63 KiB
63 KiB
In [1]:
from IPython.display import YouTubeVideo
YouTubeVideo('bxe2T-V8XRs',width=640,height=360)Out [1]:
In [18]:
# your code here (Note include needed libraries):
import numpy as np
import matplotlib.pyplot as plt
# input data (hours of sleep, hours of study)
X = np.array([[3,5],[5,1],[10,2]])
# normalized X
X_norm = X/np.amax(X)
# output data (test score)
y = np.array([[75],[82],[93]])
# normalized y
y_norm = y/100
In [8]:
from IPython.display import YouTubeVideo
YouTubeVideo('UJwK6jAStmg',width=640,height=360, align='Center')Out [8]:
In [11]:
# Put your answer here
inputLayerSize = 2
outputLayerSize = 1
hiddenLayerSize = 3In [14]:
# your code here:
W1 = np.random.randn(inputLayerSize, hiddenLayerSize)
W2 = np.random.randn(hiddenLayerSize, outputLayerSize)In [15]:
Z2 = np.dot(X_norm, W1)
Z2Out [15]:
array([[-0.85206517, -0.46315777, 0.47725383],
[-0.96041205, -1.14843537, 0.98384797],
[-1.92082411, -2.29687075, 1.96769593]])In [19]:
# your code here:
def sigmoid(z):
# apply sigmoid activation function
return 1/(1+np.exp(-z))In [23]:
testInput = np.arange(-6,6,0.01)
plt.plot(testInput, sigmoid(testInput), linewidth= 2)
plt.grid(1)
plt.show()In [24]:
a2 = sigmoid(Z2)
a2Out [24]:
array([[0.29899982, 0.38623698, 0.6170992 ],
[0.2767957 , 0.24077498, 0.72787107],
[0.1277697 , 0.09138246, 0.87736342]])In [25]:
Z3 = np.dot(a2, W2)
Z3Out [25]:
array([[1.72574334],
[1.70159205],
[1.58224372]])In [27]:
# your code here:
yHat = sigmoid(Z3)In [28]:
y_normOut [28]:
array([[0.75],
[0.82],
[0.93]])In [29]:
yHatOut [29]:
array([[0.84886714],
[0.84574255],
[0.82952205]])In [30]:
from IPython.display import HTML
HTML(
"""
<iframe
src="https://goo.gl/forms/XqTdYAtXYDSc1R7V2"
width="80%"
height="1200px"
frameborder="0"
marginheight="0"
marginwidth="0">
Loading...
</iframe>
"""
)Out [30]: