Gradient Descent
Finds local minima according to http://en.wikipedia.org/wiki/Gradient_descent
Run test_grad_descent for example.
>>The first output of the function should be the function value whereas the
>>second should be the gradient
% Inputs:
% func : the function in which to be optimised over, must
% return value as first argument and gradient as second
% x : starting point to begin optimisation
% gamma (optional) : minimising parameter, small values will get to the
% local maxima, slowly whereas bigger parameters will
% be faster but might overshoot (default 0.2)
% iter (optional) : Number of iterations over which it is optimised
% (default 100)
% thresh (optional): stopping criteria for which the function is not
% minimised any more. (default 1e-6)
% display (optional): Whether or not to display ouput of iteration,
% function value, and change (default 1)
%
% Outputs:
% x: locally optimised location
% val: f(x) i.e. the function value
Thanks,
Sachin
Cite As
Sachinthaka (2024). Gradient Descent (https://www.mathworks.com/matlabcentral/fileexchange/38588-gradient-descent), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.