这学期一直在跟进 Coursera上的 Machina Learning 公开课, 老师Andrew Ng是coursera的创始人之一,Machine Learning方面的大牛。这门课程对想要了解和初步掌握机器学习的人来说是不二的选择。这门课程涵盖了机器学习的一些基本概念和方法,同时这门课程的编程作业对于掌握这些概念和方法起到了巨大的作用。

课程地址 https://www.coursera.org/learn/machine-learning

笔记主要是简要记录下课程内容,以及MATLAB编程作业....

Neural Networks: Representation

lrCostFunction.m

 1 h_theta = sigmoid( X * theta);
2
3 eqsum = sum( -y .* log( h_theta) - (1-y) .* log( 1 - h_theta));
4
5 extra_fun = lambda / (2*m) * (theta' * theta - theta(1) * theta(1));
6 J = 1/m * eqsum + extra_fun;
7
8 E = h_theta - y;
9 grad = 1/m * X' * E + lambda / m .* theta;
10 grad(1) = grad(1) - lambda / m * theta(1);

oneVsAll.m

 1     % Set Initial theta
2 initial_theta = zeros(n + 1, 1);
3
4 % Set options for fminunc
5 options = optimset('GradObj', 'on', 'MaxIter', 50);
6
7 % Run fmincg to obtain the optimal theta
8 % This function will return theta and the cost
9 for c = 1:num_labels
10 [all_theta(c,:)] = fmincg (@(t)(lrCostFunction(t, X, (y == c), lambda)),initial_theta, options);
11 end

predictOneVsAll.m

1 h = sigmoid( X * all_theta' ); % 5000 x 401 x 401 x 10 = 5000 x 10
2 [max_value ,p] = max(h, [], 2);

predict.m

 1 X = [ones(m, 1) X];
2 % Theta1 has size 25 x 401
3 % Theta2 has size 10 x 26
4 z2 = X * Theta1'; % 5000 x 25
5 a2 = sigmoid(z2); % 5000 x 25
6 a2 = [ones(m,1) a2]; % 5000 x 26
7 z3 = a2 * Theta2'; % 5000 x 10
8 a3 = sigmoid(z3);
9
10 [max_value ,p] = max(a3, [], 2);

Andrew Ng 的 Machine Learning 课程学习 (week4) Multi-class Classification and Neural Networks的更多相关文章

  1. Andrew Ng 的 Machine Learning 课程学习 (week5) Neural Network Learning

    这学期一直在跟进 Coursera上的 Machina Learning 公开课, 老师Andrew Ng是coursera的创始人之一,Machine Learning方面的大牛.这门课程对想要了解 ...

  2. Andrew Ng 的 Machine Learning 课程学习 (week3) Logistic Regression

    这学期一直在跟进 Coursera上的 Machina Learning 公开课, 老师Andrew Ng是coursera的创始人之一,Machine Learning方面的大牛.这门课程对想要了解 ...

  3. Andrew Ng 的 Machine Learning 课程学习 (week2) Linear Regression

    这学期一直在跟进 Coursera上的 Machina Learning 公开课, 老师Andrew Ng是coursera的创始人之一,Machine Learning方面的大牛.这门课程对想要了解 ...

  4. matlab基础教程——根据Andrew Ng的machine learning整理

    matlab基础教程--根据Andrew Ng的machine learning整理 基本运算 算数运算 逻辑运算 格式化输出 小数位全局修改 向量和矩阵运算 矩阵操作 申明一个矩阵或向量 快速建立一 ...

  5. Logistic回归Cost函数和J(θ)的推导----Andrew Ng【machine learning】公开课

    最近翻Peter Harrington的<机器学习实战>,看到Logistic回归那一章有点小的疑问. 作者在简单介绍Logistic回归的原理后,立即给出了梯度上升算法的code:从算法 ...

  6. [C5] Andrew Ng - Structuring Machine Learning Projects

    About this Course You will learn how to build a successful machine learning project. If you aspire t ...

  7. 今天开始学Pattern Recognition and Machine Learning (PRML),章节5.2-5.3,Neural Networks神经网络训练(BP算法)

    转载请注明出处:http://www.cnblogs.com/xbinworld/p/4265530.html 这一篇是整个第五章的精华了,会重点介绍一下Neural Networks的训练方法——反 ...

  8. 机器学习(Machine Learning)&深度学习(Deep Learning)资料

    <Brief History of Machine Learning> 介绍:这是一篇介绍机器学习历史的文章,介绍很全面,从感知机.神经网络.决策树.SVM.Adaboost到随机森林.D ...

  9. 机器学习(Machine Learning)&深入学习(Deep Learning)资料

    <Brief History of Machine Learning> 介绍:这是一篇介绍机器学习历史的文章,介绍很全面,从感知机.神经网络.决策树.SVM.Adaboost 到随机森林. ...

随机推荐

  1. c# sql省市联动

    C# sql省市联动 USE [Book] GO ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ); ...

  2. 基于vue框架项目开发过程中遇到的问题总结(三)

    这次遇到的一个问题困扰了我很久很久,大致就是vue路由的addRoutes方法的使用,每次在调用了这个之后router对象中并没有将路由添加进去,接下来,我一步一步的分析原因及解决方法(个人见解,仅供 ...

  3. RPM软件包管理以及使用方法

    Red Hat Package Manager(简称RPM)工具包由于其使用简单操作方便,可以实现软件的查询.安装.卸载.升级和验证等功能,为Linux使用者节省大量的时间,所以被广泛的用于Linux ...

  4. 昂达v981平板刷机教程连接

    http://tieba.baidu.com/p/3721193574 http://www.ondabbs.cn/forum.php?mod=viewthread&tid=65393 htt ...

  5. CF912E Prime Gift 数学

    Opposite to Grisha's nice behavior, Oleg, though he has an entire year at his disposal, didn't manag ...

  6. c#生产/消费RabbitMQ

    public sealed class JsonSerializer { public static byte[] Serialize(object message) { return Encodin ...

  7. pandas学习2(基础操作)

  8. day15 面向对象 成员

    成员 1. 变量 1.实例变量 格式: 变量.xxx=xx (称为实例变量,也叫属性,字段)给对象用的 2.类变量 类变量:直接写在类中的变量就是类变量,类变量一般用类名来访问 其实就是类中相同的属性 ...

  9. IP 地址分类

    1.1 网络IP地址分类 网络通讯过程中数据封装与解封过程(网际互联通讯过程) TCP/IP模型 1)应用层 总结记录一些常见网络协议以及对应的端口号(FTP HTTP telnet) 2)主机到主机 ...

  10. Go语言基础之17--Redis基本操作

    一.介绍与连接 1.1 介绍 使用第三方的redis库, github.com/garyburd/redigo/redis github地址:https://github.com/gomodule/r ...