Skip to content

Instantly share code, notes, and snippets.

@freedomtowin
Last active April 20, 2018 19:15
Show Gist options
  • Save freedomtowin/badd084e950846ec808ec0e6d9f24364 to your computer and use it in GitHub Desktop.
Save freedomtowin/badd084e950846ec808ec0e6d9f24364 to your computer and use it in GitHub Desktop.
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