Skip to content
New issue

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

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

Already on GitHub? # to your account

The cost function code return opposite sign #76

Open
SendToSpace opened this issue Sep 13, 2019 · 5 comments
Open

The cost function code return opposite sign #76

SendToSpace opened this issue Sep 13, 2019 · 5 comments

Comments

@SendToSpace
Copy link

#Take the error when label=1
class1_cost = -labels*np.log(predictions)

#Take the error when label=0
class2_cost = (1-labels)*np.log(1-predictions)

#Take the sum of both costs
cost = class1_cost + class2_cost

In this code, it seem like class1 return positive cost and class2 return negative cost, wouldn't they cancel when added?

@iandanforth
Copy link

If the labels can only be 1 or 0, one of the costs will always be 0.

-0 * anything = 0

Or

1-1 * anything = 0

@SendToSpace
Copy link
Author

What I mean was, when label is 0,
(1-0)log(1-p) will give negative cost, should be (label-1)log(1-p), for positive cost, or I could be missing a point here

@iandanforth
Copy link

@SendToSpace You're correct. The - sign got moved inside the parens in the equation just above the code as well.

@bfortuner
Copy link
Owner

Nice catch if you have time for a pr that would be awesome!

@Chandu-4444
Copy link

Hey @bfortuner, Can I make a PR for this? I'm just a beginner wanted to start contributing ot Open Source.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants