吴恩达第十三课实现代价函数(matlab版本)
发布时间
阅读量:
阅读量
文章结构概述
- 1.回顾
- 2.损失函数的程序编码实现
1.回顾
设定函数表达式为:hθ(x) = θ0 + θ1x
损失函数:

2.代价函数的代码实现
当前存在一组数据集合,旨在构建一个函数用于评估代价函数J(θ),并确定不同θ参数取值情况下对应的代价函数J的具体数值。

代价函数costFunctionJ的实现代码如下:
function J = costFunctionJ(X, y, theta)
%x is the "design matrix" containing our training examples.
% y is the class labels
m= size(X,1);%number of training examples
predic
全部评论 (0)
还没有任何评论哟~
