Created
April 21, 2018 02:42
-
-
Save domarps/b21356780a8723f0243d185d99201ac2 to your computer and use it in GitHub Desktop.
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
#FC1 activation | |
z1 = np.dot(X,W1) + b1 # N X H | |
# RELU layer | |
h1 = z1.copy() # N X H | |
h1[h1 < 0] = 0 # N X H | |
#FC2 layer | |
z2 = np.dot(h1, W2) + b2 # N X C | |
#Output scores | |
scores = z2 | |
# numerical stability trick (adapted from softmax) | |
f = scores - scores.max(axis=1)[:, np.newaxis] | |
# calculate softmax | |
sum_f = np.sum(np.exp(f), axis = 1, keepdims = True) | |
softmax_scores = np.exp(f)/sum_f | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment