在Gradient Descent Algorithm中,我们应用赓续推导获得两个对此算法异常重要的公式,一个是J(θ)的求解公式,另一个是θ的求解公式:
2、梯度降低算法:
- function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
- %GRADIENTDESCENT Performs gradient descent to learn theta
- % theta = GRADIENTDESENT(X, y, theta, alpha, num_iters) updates theta by
- % taking num_iters gradient steps with learning rate alpha
- % Initialize some useful values
- m = length(y); % number of training examples
- J_history = zeros(num_iters, 1);
- for iter = 1:num_iters
- % ====================== YOUR CODE HERE ======================
- % Instructions: Perform a single gradient step on the parameter vector
- % theta.
- %
- % Hint: While debugging, it can be useful to print out the values
- % of the cost function (computeCost) and gradient here.
- %
- h=X*theta;
- e=h-y;
- theta = theta-alpha*(X'*e)/m;
- % ============================================================
- % Save the cost J in every iteration
- J_history(iter) = computeCost(X, y, theta);
- end
- end
【编辑推荐】
- 人工智能和机械进修——这些风行词你Get到了吗?
- 机械进修衔目中的数据预处理与数据整顿之比较
- 一种基于机械进修的主动化鱼叉式收集垂纶思路
- 我是若何用机械进修技巧赞助HR省时光的
- 干货|在机械进修中若何应对不均衡分类问题?
推荐阅读
四、为什么没有精确处理mail()函数的第5个参数会激发安然问题一、媒介在我们发掘PHP应用法度榜样马脚的过程中,我们向有名的Webmail办事供给商Roundcube提交了一个长途敕令履行马脚(CVE-2>>>详细阅读
地址:http://www.17bianji.com/lsqh/35047.html
1/2 1

网友点评
精彩导读
科技快报
品牌展示