Advertisement
Guest User

auto_diff_2

a guest
Jan 22nd, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. function [gradients] = auto_diff_p2(x, y, predictions)
  2.  
  3. % Initialize the gradient vector
  4. gradients = zeros([1, 3]);
  5.  
  6. % --------------- Edit From Here ---------------
  7. a = 2*(predictions -y).*(x.^2);
  8. b = 2*(predictions -y).*x;
  9. c = 2*(predictions -y);
  10.  
  11. gradients(1) = mean(a);
  12. gradients(2) = mean(b);
  13. gradients(3) = mean(c);
  14.  
  15. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement