Skip to content
Open
Changes from all commits
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
4 changes: 2 additions & 2 deletions neuralnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def cross_entropy_loss(a, y):
return np.sum(np.nan_to_num(-y*np.log(a)-(1-y)*np.log(1-a)))

def log_likelihood_loss(a, y):
return -np.dot(y, softmax(a).transpose())
return -np.nan_to_num(np.log(np.dot(y, softmax(a).transpose())))

def delta(a, y):
""" delta for both activations works out to be the same"""
Expand All @@ -97,4 +97,4 @@ def derivative(z, fn):
f = sigmoid
elif fn == SOFTMAX:
f = softmax
return f(z)*(1-f(z))
return f(z)*(1-f(z))