“ML”的版本间的差异

来自个人维基
跳转至: 导航搜索
Gradient Descent梯度下降
Gradient Descent梯度下降
第5行: 第5行:
 
=Gradient Descent梯度下降=
 
=Gradient Descent梯度下降=
 
<math>&theta;_j:=&theta;_j+&alpha;\frac{&part;}{&part;&theta;_j}J(&theta;)</math>
 
<math>&theta;_j:=&theta;_j+&alpha;\frac{&part;}{&part;&theta;_j}J(&theta;)</math>
对于线性模型,其损失函数为均方误差,故有:
+
对于线性模型,其损失函数为均方误差,故有(这里输入训练数据x为m*n矩阵, 线性参数<math>&theta;</math>为n*1):
<math>&alpha;\frac{&part;}{&part;&theta;_j}J(&theta;)= \frac{&part;}{&part;&theta;_j}(\frac{1}{2m}\sum_{i=1}^m(h_&theta;(x_i)-y_i)^2)</math>
+
<math>\frac{&part;}{&part;&theta;_j}J(&theta;)= \frac{&part;}{&part;&theta;_j}(\frac{1}{2m}\sum_{i=1}^m(h_&theta;(x_i)-y_i)^2)</math>
 
:<math>= \frac{1}{2m}\frac{&part;}{&part;&theta;_j}(\sum_{i=1}^m(h_&theta;(x_i)-y_i)^2)</math>
 
:<math>= \frac{1}{2m}\frac{&part;}{&part;&theta;_j}(\sum_{i=1}^m(h_&theta;(x_i)-y_i)^2)</math>
 
:<math>= \frac{1}{2m}\sum_{i=1}^m( \frac{&part;}{&part;&theta;_j}(h_&theta;(x_i)-y_i)^2 )</math>
 
:<math>= \frac{1}{2m}\sum_{i=1}^m( \frac{&part;}{&part;&theta;_j}(h_&theta;(x_i)-y_i)^2 )</math>

2018年12月21日 (五) 12:34的版本

Cost Function损失函数

Squared error function/Mean squared function均方误差: [math]J(θ)=\frac{1}{2m}\sum_{i=1}^m(h_θ(x_i)-y_i)^2[/math]
Cross entropy交叉熵: [math]J(θ)=-\frac{1}{m}\sum_{i=1}^m[y^{(i)}*logh_θ(x^{(i)})+(1-y^{(i)})*log(1-h_θ(x^{(i)}))][/math]

Gradient Descent梯度下降

[math]θ_j:=θ_j+α\frac{∂}{∂θ_j}J(θ)[/math]
对于线性模型,其损失函数为均方误差,故有(这里输入训练数据x为m*n矩阵, 线性参数[math]θ[/math]为n*1):
[math]\frac{∂}{∂θ_j}J(θ)= \frac{∂}{∂θ_j}(\frac{1}{2m}\sum_{i=1}^m(h_θ(x_i)-y_i)^2)[/math]

[math]= \frac{1}{2m}\frac{∂}{∂θ_j}(\sum_{i=1}^m(h_θ(x_i)-y_i)^2)[/math]
[math]= \frac{1}{2m}\sum_{i=1}^m( \frac{∂}{∂θ_j}(h_θ(x_i)-y_i)^2 )[/math]
[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) \frac{∂}{∂θ_j}h_θ(x_i) ) //链式求导法式[/math]
[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) \frac{∂}{∂θ_j}x_iθ ) [/math]
[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) \frac{∂}{∂θ_j}\sum_{k=0}^{n-1}x_{ik}θ_k ) [/math]

对于j>=1:

[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) x_{ij} ) [/math]
[math]= \frac{1}{m} (h_θ(x)-y) x_{j} [/math]