ufdl的新教程,从基础学起。第一节讲的是线性回归。主要目的是熟悉目标函数,计算梯度和优化。

按着教程写完代码后,总是编译出错,一查是mex的原因,实在不想整了。

这位博主用的是向量,比较简洁:http://blog.csdn.net/lingerlanlan/article/details/38377023

这位博主用的是循环,更好理解:http://www.cnblogs.com/william7neral/p/4448566.html

接下来是logistic regression和向量化,没什么好说的:http://blog.csdn.net/lingerlanlan/article/details/38390085

这节主要是完成liner_regression.m,包括计算目标函数f和梯度g,需要注意的是要分清变量是列向量还是行向量或是矩阵。

对matlab不太熟,所以我稍微注释了下

function [f,g] = linear_regression(theta, X,y)
%
% Arguments:
% theta - A vector containing the parameter values to optimize.列向量
% X - The examples stored in a matrix.
% X(i,j) is the i'th coordinate of the j'th example.
% y - The target value for each example. y(j) is the target for
% example j.行向量
%
%size(a,)求矩阵的行数 size(a,)求矩阵的列数,相当于length(a)
%size(a)同时求矩阵的行和列数
% m=size(X,);
m = size(X,);
n=size(X,); f=;
g=zeros(size(theta)); %
% TODO: Compute the linear regression objective by looping over the examples in X.
% Store the objective function value in 'f'.
%
% TODO: Compute the gradient of the objective with respect to theta by looping over
% the examples in X and adding up the gradient for each example. Store the
% computed gradient in 'g'. %%% YOUR CODE HERE %%%
h = theta' * X
f = (/)* (h-y)' * (h-y)
g = X * (h - y)'

最新文章

  1. I/O重定向的原理和实现
  2. 听说awk语言也可以编写脚本
  3. Apple Instruments
  4. vim插件ctags的安装和使用
  5. [Android Pro] DES加密 version1
  6. (转)distcp从ftp到hdfs拷贝文件
  7. centos 基本操作(快捷键开户终端,复制,粘贴,yum命令)
  8. java Pattern
  9. IOS学习4
  10. CentOS 7 安装 PyCharm for python
  11. [转]使用openssl库实现RSA、AES数据加密
  12. JavaSE教程-02Java基本语法
  13. Check for Palindromes-FCC
  14. SLAM+语音机器人DIY系列:(四)差分底盘设计——4.底盘ROS驱动开发
  15. eclipse集成lombok
  16. 【Node100In1】01.去异步,解决掉Node.js万恶的回调陷阱
  17. Java抽象类简单学习
  18. Get The Treasury HDU - 3642(体积扫描线)
  19. halcon之 distance_transform
  20. oracle 简单输出语句与赋值

热门文章

  1. Redis的相关问题总结
  2. Delphi DBGrid记录全选和反选拖动处理
  3. JAVA的垃圾回收机制(GC)
  4. ubuntu下java JDK环境配置
  5. linux课外命令
  6. MT【82】凸函数
  7. 一步步创建第一个Docker App —— 4. 部署应用
  8. Aop学习笔记
  9. (转)丢掉鼠标吧,使用最好用的eclipse快捷键
  10. linux c 编程 ------ 程序入口参数,即 main 参数