changeset 45:4d173452377e

notes on backpropagation
author Jeff Hammel <k0scist@gmail.com>
date Mon, 04 Sep 2017 15:19:29 -0700
parents 857a606783e1
children cb1a02a413bc
files tvii/logistic_regression.py
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/tvii/logistic_regression.py	Mon Sep 04 15:06:38 2017 -0700
+++ b/tvii/logistic_regression.py	Mon Sep 04 15:19:29 2017 -0700
@@ -15,6 +15,11 @@
 from .sigmoid import sigmoid
 
 
+def loss(a, y):
+    # UNTESTED!
+    # derivative = -(y/a) + (1-y)/(1-a)
+    return -y*np.log(a) - (1-y)*np.log(1-a)
+
 def propagate(w, b, X, Y):
     """
     Implement the cost function and its gradient for the propagation: