初级
修改梯度下降函数
未完成
初级参考
完整示例代码供参考,建议自己理解后重新输入
def gradient_descent3(f,xstart,ystart,zstart,tolerance=1e-6,max_steps=1000):
x = xstart
y = ystart
z = zstart
grad = approx_gradient3(f,x,y,z)
steps = 0
while length(grad) > tolerance and steps < max_steps:
x -= 0.01 * grad[0]
y -= 0.01 * grad[1]
z -= 0.01 * grad[2]
grad = approx_gradient3(f,x,y,z)
steps += 1
print(steps)
return x,y,z
示例
输入
solve()
期望输出
输出结果
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199