practical-cnn icon indicating copy to clipboard operation
practical-cnn copied to clipboard

quastion about derivative - part 2

Open sdahan12 opened this issue 9 years ago • 0 comments

hi, in part 2 there is a calculation of dzdx_empirical , can somone help and explain the calculation? why is there a sum? and why is there a division by eta and not a division by etx*ex (as i expected to be)?

thanks!

% Check the derivative numerically ex = randn(size(x), 'single') ; eta = 0.0001 ; xp = x + eta * ex ; yp = vl_nnconv(xp, w, []) ;

dzdx_empirical = sum(dzdy(:) .* (yp(:) - y(:)) / eta) ; dzdx_computed = sum(dzdx(:) .* ex(:)) ;

fprintf(... 'der: empirical: %f, computed: %f, error: %.2f %%\n', ... dzdx_empirical, dzdx_computed, ... abs(1 - dzdx_empirical/dzdx_computed)*100) ;

sdahan12 avatar Nov 27 '16 20:11 sdahan12