# HG changeset patch # User Jeff Hammel # Date 1513547022 28800 # Node ID 3c7927f59b05ad3e6610e60994e8aa3e1b9d31e9 # Parent cecea2334eefab8e8d13f2409ef67a93ad0dbc91 notes to self re deep neural networks diff -r cecea2334eef -r 3c7927f59b05 tvii/deep.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tvii/deep.py Sun Dec 17 13:43:42 2017 -0800 @@ -0,0 +1,44 @@ +""" +Deep neural networks + +Forward propagation for layer `l` + +Input: a[l-1] + +Output: a[l], cache(z[l] {w[l], b[1]}) + +z[l] = w[l] ... + +--- + +Backward propagation for layer `l`: + +Input: da[l] +Output: da[l-1], dW[l], db[l] + +dz[l] = da[l]* g[l]'(z[l]) +dw[l] = dz[l] a[l-1] +db[l] = dz[l] +dz[l-1] w[l].T dz[l] + +dz[l] = w[l+1].T dz[l+1] * g[l]' ( z[l] ) + +=> + +dZ[l] dZ[l] * g[l]' ( Z[l] ) + +dW[l] (1/m) dZ[l] A[l-1].T + +db[l] = (1/m) np.dum(dZ[l], axis=1, keepdims=True) +dA[l-1] = W[l].T * dZ[l] + + +For the final layerL +da[l] = - (y/a) + (1 - y)/(1-a) +dA[l] = (-(y(1)/a(1) + (1 - y(1))/(1 - a(1)) # first training example + ...) + + +The weight matrix for layer `l`, W[l] is +of the shape (n[l], n[l-1]) +"""