[Coursera][Stanford] Machine Learning Week 4

时间:8月16日 -- 18 日


1. Neural Network: Repressentation 神经网络

Logistic unit, Neural Network, AND、OR、NOT运算


2. Multiple output units: one -vs -all


学习的问题已渐渐显现,讲课能够明白,但做习题已经不能集中精神完全机械的按照提示一步一步来,完全没有理解习题3

看到做的总结就知道了,没写什么,虽然第四周的课确实不多。

[ml-class] Submitted Assignment 3 - Part 1 - Vectorized Logistic Regression 一定写错了,因为提交时明显迭代次数重复过多,但是不知为什么系统一直说Nice work!。。。。。。。。。。。。。人品好?今晚写这个习题越写越头痛,一定要再做一次!

Programming Exercise 3:
Multi-class Classification and Neural Networks


1 Multi-class Classification

1.3 Vectorizing Logistic Regression

1.3.1 Vectorizing the cost function

1.3.2 Vectorizing the gradient

1.3.3 Vectorizing regularized logistic regression

h = 1 ./ (1 + exp(- X * theta));
J = - (1 / m) * ((y' * log(h)) + (1 - y)' * log(1 - h)) + (lambda / (2 * m)) * sum(theta(2:end) .^ 2);

% 1st
grad = (1 / m) * X' * (h - y) + (lambda /  m) * [0;theta(2:end)];
% 2nd
%grad = (1 / m) * X' * (h - y);
%temp = theta; 
%temp(1) = 0;   % because we don't add anything for j = 0  
%grad = grad + (lambda /  m) * temp;

总感觉好像是不是这里出问题了?

1.4 One-vs-all Classification

%     % Set Initial theta
initial_theta = zeros(n + 1, 1);
%     
%     % Set options for fminunc
options = optimset('GradObj', 'on', 'MaxIter', 50);

for c = 1:num_labels
    [theta] = fmincg (@(t)(lrCostFunction(t, X, (y == c), lambda)), initial_theta, options);
    all_theta(c,:) = theta;
end

1.4.1 One-vs-all Prediction

[x,p] = max(X * all_theta' , [], 2);

2 Neural Networks

2.2 Feedforward Propagation and Prediction

X = [ones(m, 1) X];
X = [ones(m, 1) sigmoid(X * Theta1')];
[x,p] = max(sigmoid(X * Theta2'),[],2);


最终提交显示结果如下,哪里不对啊。。。 难过

>> submit
==
== [ml-class] Submitting Solutions | Programming Exercise 3
==
== Select which part(s) to submit:
==   1) Vectorized Logistic Regression  [ lrCostFunction.m ]
==   2) One-vs-all classifier training [ oneVsAll.m ]
==   3) One-vs-all classifier prediction [ predictOneVsAll.m ]
==   4) Neural network prediction function [ predict.m ]
==   5) All of the above 
==
Enter your choice [1-5]: 5
You are currently logged in as liuyanfight@foxmail.com.
Is this you? (y/n - type n to reenter password)y

== Connecting to ml-class ... 
== [ml-class] Submitted Assignment 3 - Part 1 - Vectorized Logistic Regression 
== Nice work!
Iteration     1 | Cost: 4.749342e-01
Iteration     2 | Cost: 3.951798e-01
Iteration     3 | Cost: 3.410009e-01
Iteration     4 | Cost: 3.408546e-01
Iteration     5 | Cost: 3.402400e-01
Iteration     6 | Cost: 3.397496e-01
Iteration     7 | Cost: 3.395172e-01
Iteration     8 | Cost: 3.391977e-01
Iteration     9 | Cost: 3.391811e-01
Iteration    10 | Cost: 3.391637e-01
Iteration    11 | Cost: 3.391498e-01
Iteration    12 | Cost: 3.391382e-01
Iteration    13 | Cost: 3.391350e-01
Iteration    14 | Cost: 3.391343e-01
Iteration    15 | Cost: 3.391340e-01
Iteration    16 | Cost: 3.391340e-01
Iteration    17 | Cost: 3.391340e-01
Iteration    18 | Cost: 3.391340e-01
Iteration    19 | Cost: 3.391340e-01
Iteration    20 | Cost: 3.391340e-01
Iteration    21 | Cost: 3.391340e-01
Iteration    22 | Cost: 3.391340e-01
Iteration    23 | Cost: 3.391340e-01
Iteration    24 | Cost: 3.391340e-01
Iteration    25 | Cost: 3.391340e-01
Iteration    26 | Cost: 3.391340e-01
Iteration    27 | Cost: 3.391340e-01
Iteration    28 | Cost: 3.391340e-01
Iteration    29 | Cost: 3.391340e-01
Iteration    30 | Cost: 3.391340e-01
Iteration    31 | Cost: 3.391340e-01
Iteration    32 | Cost: 3.391340e-01
Iteration    34 | Cost: 3.391340e-01

Iteration     1 | Cost: 1.934937e-01
Iteration     2 | Cost: 1.557194e-01
Iteration     3 | Cost: 1.037875e-01
Iteration     4 | Cost: 7.802805e-02
Iteration     5 | Cost: 6.676458e-02
Iteration     6 | Cost: 6.647775e-02
Iteration     7 | Cost: 6.637033e-02
Iteration     8 | Cost: 6.631655e-02
Iteration     9 | Cost: 6.631456e-02
Iteration    10 | Cost: 6.631440e-02
Iteration    11 | Cost: 6.631439e-02
Iteration    12 | Cost: 6.631438e-02
Iteration    13 | Cost: 6.631438e-02
Iteration    14 | Cost: 6.631438e-02
Iteration    15 | Cost: 6.631438e-02
Iteration    16 | Cost: 6.631438e-02
Iteration    17 | Cost: 6.631438e-02
Iteration    18 | Cost: 6.631438e-02
Iteration    19 | Cost: 6.631438e-02
Iteration    20 | Cost: 6.631438e-02
Iteration    21 | Cost: 6.631438e-02
Iteration    22 | Cost: 6.631438e-02
Iteration    23 | Cost: 6.631438e-02
Iteration    24 | Cost: 6.631438e-02
Iteration    25 | Cost: 6.631438e-02
Iteration    26 | Cost: 6.631438e-02

Iteration     1 | Cost: 3.899941e-01
Iteration     2 | Cost: 3.371335e-01
Iteration     3 | Cost: 2.080753e-01
Iteration     4 | Cost: 1.142276e-01
Iteration     5 | Cost: 1.139130e-01
Iteration     6 | Cost: 1.095794e-01
Iteration     7 | Cost: 1.012910e-01
Iteration     8 | Cost: 1.003343e-01
Iteration     9 | Cost: 1.002875e-01
Iteration    10 | Cost: 1.002708e-01
Iteration    11 | Cost: 1.002660e-01
Iteration    12 | Cost: 1.002639e-01
Iteration    13 | Cost: 1.002636e-01
Iteration    14 | Cost: 1.002636e-01
Iteration    15 | Cost: 1.002636e-01
Iteration    16 | Cost: 1.002636e-01
Iteration    17 | Cost: 1.002636e-01
Iteration    18 | Cost: 1.002636e-01
Iteration    19 | Cost: 1.002636e-01
Iteration    20 | Cost: 1.002636e-01
Iteration    21 | Cost: 1.002636e-01
Iteration    22 | Cost: 1.002636e-01
Iteration    23 | Cost: 1.002636e-01
Iteration    24 | Cost: 1.002636e-01
Iteration    25 | Cost: 1.002636e-01
Iteration    26 | Cost: 1.002636e-01
Iteration    27 | Cost: 1.002636e-01
Iteration    28 | Cost: 1.002636e-01
Iteration    29 | Cost: 1.002636e-01
Iteration    30 | Cost: 1.002636e-01
Iteration    31 | Cost: 1.002636e-01

Iteration     1 | Cost: 4.202132e-01
Iteration     2 | Cost: 3.970889e-01
Iteration     3 | Cost: 3.673914e-01
Iteration     4 | Cost: 3.642254e-01
Iteration     5 | Cost: 3.611087e-01
Iteration     6 | Cost: 3.598573e-01
Iteration     7 | Cost: 3.598359e-01
Iteration     8 | Cost: 3.598130e-01
Iteration     9 | Cost: 3.598122e-01
Iteration    10 | Cost: 3.598119e-01
Iteration    11 | Cost: 3.598119e-01
Iteration    12 | Cost: 3.598119e-01
Iteration    13 | Cost: 3.598119e-01
Iteration    14 | Cost: 3.598119e-01
Iteration    15 | Cost: 3.598119e-01
Iteration    16 | Cost: 3.598119e-01


== [ml-class] Submitted Assignment 3 - Part 2 - One-vs-all classifier training
== Nice work!

== [ml-class] Submitted Assignment 3 - Part 3 - One-vs-all classifier prediction
== Nice work!

== [ml-class] Submitted Assignment 3 - Part 4 - Neural network prediction function
== You must wait 4 minutes and 7 seconds before you can submit your solutions again.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值