UFLDL课程学习(二)

章节地址:http://ufldl.stanford.edu/tutorial/supervised/LogisticRegression/

章节名称:逻辑回归 (Logisitic Regression)

第二章的主要问题是什么?是内存不够,艹

Error using fread
Out of memory. Type HELP MEMORY for your options.

说明一下,其实都是我的错,我的电脑是32位机


因为机子的关系,所以这里只是意淫一下结果,并做一下分析

对于逻辑回归中的能量函数J(),如下:

首先,函数h(x)的范围是(0,1),所以log(h(x))的范围是(负无穷,0),所以原文中说 当y=1时,目标是让log(h(x))尽量大是正确的,因为最大值是0。(When y(i)=1 minimizing the cost function means we need to make hθ(x(i)) large)


下面是代码,效果由于我不能运行,之后再贴吧:

%%% YOUR CODE HERE %%%
%   h = sigmoid(theta'*X);
%   f = -y*log2(h)'+(1-y)*log2(1-h)';
%   g = (h-y)*X;
  h = sigmoid(X'*theta);  
  f=-y*log2(h)+(1-y)*log2(1-h);  
  g=X*(h-y');

 

posted @ 2015-04-23 13:42  Neral  阅读(327)  评论(0编辑  收藏  举报