Batch Gradient Descent(python)
来源:互联网 发布:软件测试的原理 编辑:程序博客网 时间:2024/05/16 02:12
import numpy as npimport tensorflow as tfdef GradientDescent(x,y,theta): m, n = x.shape # m is #training example,while n is #feature for j in range(n): #learning rate:0.03 theta[j] = theta[j] + 0.03/m * np.sum(([(y[i] -np.matmul(x[i,:],theta))*x[i,j] for i in range(m)])) return thetax = np.array([[1],[2],[3],[4],[5],[6]])y = np.array([5,7,9,11,13,15])
#the stop conditonepison = 0.01
#add x0=1 to the datax1 = np.hstack((np.ones((6,1)), x))theta = np.zeros((2,1))# m,n = x1.shapeprint(x1.shape)while(True): theta = GradientDescent(x1, y, theta) prediction = np.matmul(x1, theta) loss = np.sum((prediction.T - y)**2) if loss < epison: breakprint('prediction=',prediction.T)print('y=',y)print('loss=',loss)
阅读全文
0 0
- Batch Gradient Descent(python)
- Batch & Stochatic Gradient Descent
- batch&stochasic gradient descent
- Batch Gradient Descent
- Mini-Batch Gradient Descent
- Batch Gradient Descent and Stochastic Gradient Descent
- Stochastic gradient descent与Batch gradient descent
- BGD(Batch Gradient Descent), SGD (Stochastic Gradient Descent), MBGD (Mini-Batch Gradient Descent)
- Stochastic Gradient Descent vs Batch Gradient Descent vs Mini-batch Gradient Descent
- batch gradient descent和stochastic/incremental gradient descent
- gradient descent vs (mini-batch) stochastic gradient descent
- Mini-Batch Gradient Descent介绍以及如何决定Batch Size
- gradient descent 的python实现
- batch gradient descent(批量梯度下降) 和 stochastic gradient descent(随机梯度下降)
- 随机梯度下降(Stochastic gradient descent)和 批量梯度下降(Batch gradient descent )
- batch gradient descent(批量梯度下降) 和 stochastic gradient descent(随机梯度下降)
- 随机梯度下降(Stochastic gradient descent)和 批量梯度下降(Batch gradient descent )
- 【机器学习学习过程中的笔记1——Stochastic gradient descent 和 Batch gradient descent 】
- python之find_all
- 录制视频
- spring aop中的After throwing增强问题
- HDU
- gson解析xml
- Batch Gradient Descent(python)
- [LeetCode] 238. Product of Array Except Self
- SSM框架下利用AJAX传递数据到Controller的一些方式
- 图像的遍历
- Java服务端过滤敏感词的思路
- Glusterfs学习笔记
- POJ2186-Popular Cows
- leetcode -- 67. Add Binary【统一形式简化代码+双指针 + 二进制规则 + 字符数字转换】
- 【二分图】poj 3041 Asteroids