Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [gradients] = auto_diff_p2(x, y, predictions)
- % Initialize the gradient vector
- gradients = zeros([1, 3]);
- % --------------- Edit From Here ---------------
- a = 2*(predictions -y).*(x.^2);
- b = 2*(predictions -y).*x;
- c = 2*(predictions -y);
- gradients(1) = mean(a);
- gradients(2) = mean(b);
- gradients(3) = mean(c);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement