1. 首页
  2. 人工智能
  3. 机器学习
  4. 批量梯度下降法python具体实现

批量梯度下降法python具体实现

上传者: 2019-01-18 17:38:00上传 PY文件 1.27KB 热度 41次
批量梯度下降法python具体实现, np.random.seed(666) x = 2 * np.random.random(size = 100) y = x * 3.0 + 4.0 + np.random.normal(size = 100) X = x.reshape(-1, 1) #损失函数 def J(theta, X_b, y): try: return np.sum((y - X_b.dot(theta))**2)/len(X_b) except: return float('inf') #损失函数的梯度 def dJ(the
用户评论