Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added SparseCategoricalCrossEntropy Loss Function #40

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'master' into edit_branch
quadri-haider-ali authored Oct 6, 2020
commit efbf0ac6e41b7ff71b5b7731a6eb9d4f27c425cb
19 changes: 16 additions & 3 deletions MLlib/loss_func.py
Original file line number Diff line number Diff line change
@@ -29,6 +29,12 @@ def derivative(X, Y, W):
return (1/M)*(np.dot(X.T, (H-Y).T))


class AbsoluteError():
@staticmethod
def loss(X, Y, W):
M = X.shape[0]
return np.sum(np.absolute(np.dot(X, W).T - Y)) / M

class SparseCategoricalCrossEntropy():
@staticmethod
def loss(X,Y,W,n):
@@ -53,6 +59,13 @@ def loss(X,Y,W,n):

@staticmethod
def derivative(X, Y, W):
M=X.shape[0]
H=sigmoid(X)
return (1/M)*(np.dot(X.T, (H-T).T))
M = X.shape[0]
AbsError = (np.dot(X, W).T-Y)
return np.dot(
np.divide(
AbsError,
np.absolute(AbsError),
out=np.zeros_like(AbsError),
where=(np.absolute(AbsError)) != 0),
X
).T/M
You are viewing a condensed version of this merge commit. You can view the full changes here.