We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 074671c commit affbb03Copy full SHA for affbb03
code/network2.py
@@ -43,10 +43,12 @@ class CrossEntropyCost:
43
@staticmethod
44
def fn(a, y):
45
"""Return the cost associated with an output ``a`` and desired output
46
- ``y``.
+ ``y``. Note that the np.nan_to_num ensures that if the output
47
+ from the network is exactly right, then 0.0 will be returned,
48
+ rather than nan.
49
50
"""
- return np.sum(-y*np.log(a)-(1-y)*np.log(1-a))
51
+ return np.nan_to_num(np.sum(-y*np.log(a)-(1-y)*np.log(1-a)))
52
53
54
def delta(z, a, y):
0 commit comments