Question: Introduction to Gradient Descent My Solutions > Write a function that finds the minimum value of a vector using gradient descent. The function accepts 1
Introduction to Gradient Descent
My Solutions
Write a function that finds the minimum value of a vector using gradient descent.
The function accepts input vector the data within which we are finding the minimum value and has output arguments: the minimum value and the number of times the algorithm had to run to get there.
function minimum numberofsteps gradientdescentintroinputvector
The initial step size for the decent should be half the length of the inputvector and the stepsize should be halved at each step until it reaches where it will stay until the code concludes.
Start at the first index in the vector.
if the derivative is positive, go left. if it's negative, go right. make sure your index does not go out of bounds. the minimum index is the maximum index is lengthinputvector
keep track of the last values of the function and stop the algorithm once a value reappears.
EXAMPLE
If the sequence of values is
then the sequence of "minimums" should be something like
then the function should return that is the minimum and that it took steps to find it
Function
Save
Reset
MATLAB Documentation
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
