vedaldi / practical-cnn

A VGG practical on convolutional neural networks
154 stars 75 forks source link

quastion about derivative - part 2 #22

Open sdahan12 opened 7 years ago

sdahan12 commented 7 years ago

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) ;