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

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

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

Neural Networks

Week4 编程作业核心代码

nnCostFunction.m

 1 %首先把原先label表示的y变成向量模式的output
2 y_vect = zeros(m,num_labels); %5000x10
3 for i = 1:m,
4 y_vect(i,y(i)) = 1;
5 end;
6
7 a1 = [ones(m, 1) X];
8 z2 = a1 * Theta1';
9 a2 = sigmoid(z2); % 5000 x 25
10 a2 = [ones(m,1) a2]; % 5000 x 26
11 z3 = a2 * Theta2'; % 5000 x 10
12 a3 = sigmoid(z3); % 5000 x 10
13
14 for i = 1:m
15 J = J + sum(-1*y_vect(i,:).*log(a3(i,:))-(1-y_vect(i,:)).*log(1-a3(i,:)));
16 end
17 J = J/m;
18 J = J + lambda*(sum(sum(Theta1(:,2:end).^2))+sum(sum(Theta2(:,2:end).^2)))/2/m;
19
20 %backward propagation
21 Delta1 = zeros(size(Theta1)); %25x401
22 Delta2 = zeros(size(Theta2)); %10x26
23 for i=1:m
24 delta3 = a3(i,:)' - y_vect(i,:)'; %10x1
25 tempTheta2 = Theta2' * delta3; % 26x10x10x1 = 26x1
26 delta2 = tempTheta2(2:end) .* sigmoidGradient(z2(i,:)'); %25x1
27 Delta2 = Delta2 + delta3 * a2(i,:); % 10x1x1x26
28 Delta1 = Delta1 + delta2 * a1(i,:); %25x1x1x401
29 end;
30
31 Theta2_grad = Delta2/m;
32 Theta1_grad = Delta1/m;
33
34 %regularization gradient
35
36 Theta2_grad(:,2:end) = Theta2_grad(:,2:end) + lambda * Theta2(:,2:end) / m;
37 Theta1_grad(:,2:end) = Theta1_grad(:,2:end) + lambda * Theta1(:,2:end) / m;
38

sigmoidGradient.m

1 g = sigmoid(z) .* ( 1 - sigmoid(z));

Andrew Ng 的 Machine Learning 课程学习 (week5) Neural Network Learning的更多相关文章

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

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

  2. [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 ...

  3. (转载)林轩田机器学习基石课程学习笔记1 — The Learning Problem

    (转载)林轩田机器学习基石课程学习笔记1 - The Learning Problem When Can Machine Learn? Why Can Machine Learn? How Can M ...

  4. 【RS】Automatic recommendation technology for learning resources with convolutional neural network - 基于卷积神经网络的学习资源自动推荐技术

    [论文标题]Automatic recommendation technology for learning resources with convolutional neural network ( ...

  5. Deep Learning: Assuming a deep neural network is properly regulated, can adding more layers actually make the performance degrade?

    Deep Learning: Assuming a deep neural network is properly regulated, can adding more layers actually ...

  6. Andrew Ng 的 Machine Learning 课程学习 (week4) Multi-class Classification and Neural Networks

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

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

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

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

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

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

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

随机推荐

  1. Python如何打包EXE可执行文件

    一.安装Pyinstaller 使用Python打包EXE可执行文件时,需要使用Pyinstaller,使用命令pip install PyInstaller进行安装,如下图: 安装成功后的效果如下图 ...

  2. SqlServer学习笔记【暂】

    Sql学习笔记,暂时先保存在着,等不忙了再整理成章节,如果其中有问题的,还请各位大神不吝赐教! --------------------------------------所有的数据基于Northwi ...

  3. 解读人:董鑫,Disease Development Is Accompanied by Changes in Bacterial Protein Abundance and Functions in a Refined Model of Dextran Sulfate Sodium (DSS)-Induced Colitis

    文章中文名:在葡聚糖硫酸钠(DSS)诱导下的结肠炎模型伴随着细菌蛋白质丰度和功能的改变 单位: 1 Helmholtz-Centre for Environmental Research - UFZ, ...

  4. 【NOIP 2013】积木大赛

    描述 春春幼儿园举办了一年一度的“积木大赛”.今年比赛的内容是搭建一座宽度为 n 的大厦,大厦可以看成由 n 块宽度为1的积木组成,第

  5. StackOverflow

    stackoverflow栈溢出 stacker栈式存储器 signup注册  signin登陆 inbox收信信箱 verify 核实 otherwise另外的 noted说明  (就是说有明文指出 ...

  6. 关于logrotate工具的日志切割

    logrotate是一个非常好的文件切割工具!! 具体配置如下: /var/log/debug.log{         daily            ; 每天转储         rotate ...

  7. ssm中实现excle导入导出

    1 pom.xml <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-oox ...

  8. 各平台安装和使用Docker的差异

    在Mac上运行Docker 使用Docker for Mac 系统要求 开启虚拟化的硬件支持,可以通过命令来检查:sysctl kern.hv_support OS X 10.10.3 或者更高版本 ...

  9. Set去掉重复的元素

    String[] uids= request.getParameterValues("dxus");获取页面传过来的id //--------------------------- ...

  10. Codeforces Round #334(div.2) A

    A. Uncowed Forces time limit per test 1 second memory limit per test 256 megabytes input standard in ...