Created
April 12, 2017 09:42
-
-
Save pratos/689f28f43e5dc473dee79175bfe065a6 to your computer and use it in GitHub Desktop.
CS231n Softmax (Cross-entropy loss) - Vectorized
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 | |
W = np.array([(0.01,-0.05,0.1,0.05),(0.7,0.2,0.05,0.16),(0.0,-0.45,-0.2, 0.03)]) #Weights | |
xi = np.array([-15,22,-44,56]) #Input | |
b = np.array([0.0,0.2,-0.3]) #Bias | |
delta = 1 | |
y = np.sum((np.dot(W,xi),b), axis=0) | |
p = np.exp(y)/np.sum(np.exp(y)) | |
final = -np.log(p[p.size-1]) | |
# final = 1.0401905694301092 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment