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 1 input vector (the data within which we are finding the minimum value), and has 2 output arguments: the minimum value and the number of times the algorithm had to run to get there.
function [minimum, number_of_steps]= gradient_descent_intro(input_vector)
The initial step size for the decent should be half the length of the input_vector and the step_size should be halved at each step until it reaches 1, 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 1, the maximum index is length(input_vector)
keep track of the last 2 values of the function and stop the algorithm once a value reappears.
EXAMPLE
If the sequence of values is -2.8,-2.9,-2.999999,-3.000000,-2.8
then the sequence of "minimums" should be something like
-2.8
-2.9
-3.000000
-2.999999
-3.000000
then the function should return that -3.000000 is the minimum and that it took 5 steps to find it.
Function
Save
Reset
MATLAB Documentation
Introduction to Gradient Descent My Solutions >

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!