Mercurial > hg > machine-learning-hw4
view sigmoidGradient.m @ 9:8dd249e99b5b default tip
Optimisations for backprop
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 11 Nov 2011 20:36:02 -0500 |
parents | 55430128adcd |
children |
line wrap: on
line source
function g = sigmoidGradient(z) ##SIGMOIDGRADIENT returns the gradient of the sigmoid function ##evaluated at z ## g = SIGMOIDGRADIENT(z) computes the gradient of the sigmoid function ## evaluated at z. This should work regardless if z is a matrix or a ## vector. In particular, if z is a vector or matrix, you should return ## the gradient for each element. s = @(z) 1./(1 + exp(-z)); g = s(z).*(1 - s(z)); endfunction