(文末包含完整代码)
导入需要的包
import numpy as np
import matplotlib.pyplot as plt
定义函数
def get_y(x):
y = x**2 + x*2 + 1
return y
计算梯度
def get_gradient(x):
getgradient = 2*x + 2
return getgradient
采用梯度下降计算函数最小值时自变量的值
def get_x_star(x0,lr,epochs,lists):
for i in range(epochs)
标签:get,python,梯度,getgradient,epochs,Python,import,def
From: https://blog.csdn.net/qq_41755239/article/details/136877620