Last active
April 20, 2018 19:15
-
-
Save freedomtowin/badd084e950846ec808ec0e6d9f24364 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
def liklihood_loss(x,y,w): | |
hypothesis = x.dot(w) | |
hypothesis = 1/(1+np.exp(-1*hypothesis)) | |
hypothesis[hypothesis<=0.00001] = 0.00001 | |
loss = -1*((1-y).T.dot(np.log(1-hypothesis)) + y.T.dot(np.log(hypothesis)))/len(y) | |
return loss.flatten()[0] | |
def sin_least_sqs_loss(x,y,w): | |
hypothesis = w[0]*x[:,0:1] + np.cos(x[:,1:2]*w[1]-w[2])*w[3] | |
loss = hypothesis-y | |
return np.sum(loss**2)/len(y) | |
def complex_sin_least_sqs_loss(x,y,w): | |
hypothesis = w[0]*x[:,0:1] + w[6]*(np.cos(x[:,1:2]*w[1]-w[2])*w[3] + np.sin(x[:,1:2]*w[4]-w[5])*w[3]) | |
loss = hypothesis-y | |
return np.sum(loss**2)/len(y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment