Merge pull request #338 from gdahia/fix-readme-toy-example

Change implementation of negative log-likelihood in README toy example
This commit is contained in:
Matthew Johnson 2019-02-08 11:13:55 -08:00 committed by GitHub
commit 0ca0968533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -243,8 +243,8 @@ def logistic_predictions(weights, inputs):
# Training loss is the negative log-likelihood of the training labels.
def loss(weights, inputs, targets):
preds = logistic_predictions(weights, inputs)
label_probs = preds * targets + (1 - preds) * (1 - targets)
return -np.sum(np.log(label_probs))
label_logprobs = np.log(preds) * targets + np.log(1 - preds) * (1 - targets)
return -np.sum(label_probs)
# Build a toy dataset.
inputs = np.array([[0.52, 1.12, 0.77],