Skip to content

Commit

Permalink
Improved documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
cgpotts committed Mar 31, 2019
1 parent 66580c3 commit 3147aa4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion np_model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,20 @@ def fit(self, X, y):

@staticmethod
def get_error(predictions, labels):
# Cross-entropy error reduces to -log(prediction-for-correct-label).
"""Cross-entropy error: -log(prediction-for-correct-label).
Parameters
----------
predictions : np.array
Predicted probabilities for each class
labels : np.array
One-hot encoded vector.
Returns
-------
float
"""
return -np.log(predictions[np.argmax(labels)])

@staticmethod
Expand Down

0 comments on commit 3147aa4

Please sign in to comment.