Data Science Projects
with Python by Stephen Klosterman

Data Science Projects
with Python by Stephen Klosterman

Author:Stephen Klosterman
Language: eng
Format: epub
Publisher: Packt Publishing Pvt. Ltd.
Published: 2019-04-29T00:00:00+00:00


Perform 14 iterations to converge toward the local minimum of the cost function by using the following code snippet (note that iterations = 15 but the endpoint is not included in the call to range()):iterations = 15

x_path = np.empty(iterations,)

x_path[0] = x_start

for iteration_count in range(1,iterations):

derivative = gradient(x_path[iteration_count-1])

x_path[iteration_count] = x_path[iteration_count-1] - (derivative*learning_rate)

x_path

You will obtain the following output:

array([ 4.5 , -0.75 , 1.875 , 0.5625 , 1.21875 ,

0.890625 , 1.0546875 , 0.97265625, 1.01367188, 0.99316406,

1.00341797, 0.99829102, 1.00085449, 0.99957275, 1.00021362])

From the resulting values of the gradient descent process, it looks like (by the end) we've gotten very close (1.00021362) to the optimal solution (1).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.