神经网络作业: NN LEARNING Coursera Machine Learning(Andrew Ng) WEEK 5
在WEEK 5中,作业要求完成通过神经网络(NN)实现多分类的逻辑回归(MULTI-CLASS LOGISTIC REGRESSION)的监督学习(SUOERVISED LEARNING)来识别阿拉伯数字。作业主要目的是感受如何在NN中求代价函数(COST FUNCTION)和其假设函数中各个参量(THETA)的求导值(GRADIENT DERIVATIVE)(利用BACKPROPAGGATION)。
难度不高,但问题是你要习惯使用MATLAB的矩阵QAQ,作为一名蒟蒻,我已经狗带了。以下代核心部分的代码希望给被作业卡住的同学一些帮助。但请不要照搬代码哦~不要~不要~
ty = zeros(m, num_labels); for i=:m
for j=:num_labels
if y(i)==j
ty(i,j) = ;
end
end
end a1 = X;
a1 = [ones(size(a1,),) a1];
z2 = a1 * Theta1';
a2 = sigmoid(z2);
a2 = [ones(size(a2,),) a2];
z3 = a2 * Theta2';
a3 = sigmoid(z3); for i=:m
for j=:num_labels
J = J - log(-a3(i,j))*(-ty(i,j))/m-log(a3(i,j))*ty(i,j)/m;
end
end %size(J,)
%size(J,) d3 = a3 - ty;
d2 = (d3 * Theta2(:,:end)).*sigmoidGradient(z2);
Theta1_grad = Theta1_grad + d2'*a1/m;
Theta2_grad = Theta2_grad + d3'*a2/m; % -------------------------------------------------------------
JJ=; for i=:size(Theta1,)
for j=:size(Theta1,)
JJ = JJ + Theta1(i,j)*Theta1(i,j)*lambda/(m*);
end
end
size(Theta1,);
size(Theta1,); for i=:size(Theta2,)
for j=:size(Theta2,)
JJ = JJ + Theta2(i,j)*Theta2(i,j)*lambda/(*m);
end
end
size(Theta2,);
size(Theta2,);
%J = J + (lambda/(*m)) * (Theta1(:,:end).*Theta1(:,:end)+Theta2(:end,:).*Theta2(:end,:));
J =J+JJ; Theta1_gradd = zeros(size(Theta1));
Theta2_gradd = zeros(size(Theta2)); for i=:size(Theta1,)
for j=:size(Theta1,)
Theta1_gradd(j,i) = Theta1(j,i)*lambda/m;
end
end for i=:size(Theta2,)
for j=:size(Theta2,)
Theta2_gradd(j,i) = Theta2(j,i)*lambda/m;
end
end Theta1_grad = Theta1_gradd+Theta1_grad;
Theta2_grad = Theta2_gradd+Theta2_grad;
PS:博主蒟蒻强迫自己下次要写矩阵运算,不能再套循环啦!!!
神经网络作业: NN LEARNING Coursera Machine Learning(Andrew Ng) WEEK 5的更多相关文章
- 《Learning scikit-learn Machine Learning in Python》chapter1
前言 由于实验原因,准备入坑 python 机器学习,而 python 机器学习常用的包就是 scikit-learn ,准备先了解一下这个工具.在这里搜了有 scikit-learn 关键字的书,找 ...
- Coursera, Machine Learning, notes
Basic theory (i) Supervised learning (parametric/non-parametric algorithms, support vector machine ...
- Machine Learning - 第6周(Advice for Applying Machine Learning、Machine Learning System Design)
In Week 6, you will be learning about systematically improving your learning algorithm. The videos f ...
- Machine Learning - XI. Machine Learning System Design机器学习系统的设计(Week 6)
http://blog.csdn.net/pipisorry/article/details/44119187 机器学习Machine Learning - Andrew NG courses学习笔记 ...
- Coursera machine learning 第二周 编程作业 Linear Regression
必做: [*] warmUpExercise.m - Simple example function in Octave/MATLAB[*] plotData.m - Function to disp ...
- Coursera Machine Learning 作业答案脚本 分享在github上
Github地址:https://github.com/edward0130/Coursera-ML
- Coursera machine learning 第二周 quiz 答案 Linear Regression with Multiple Variables
https://www.coursera.org/learn/machine-learning/exam/7pytE/linear-regression-with-multiple-variables ...
- 【Coursera - machine learning】 Linear regression with one variable-quiz
Question 1 Consider the problem of predicting how well a student does in her second year of college/ ...
- Coursera, Machine Learning, Anomoly Detection & Recommender system
Algorithm: When to select Anonaly detection or Supervised learning? 总的来说guideline是如果positive e ...
随机推荐
- NSSet和NSMutableSet 确保数据的唯一性--备
NSSet和NSMutableSet是无序的, 但是它保证数据的唯一性.当插入相同的数据时,不会有任何效果.从内部实现来说是hash表,所以可以常数时间内查找一个数据. 1.NSSet的使用 [NSS ...
- Android Timer的使用
1:服务端使用PHP <?php echo date('Y-m-d H:i:s'); ?> 2:activity_main.xml <RelativeLayout xmlns:and ...
- target vs currentTarget, clientWidth vs offsetWidth
width: document < window(browser) < screen document--> clientWidth < offsetWidth(include ...
- 上传文件 file upload 学习笔记
这里我只会说说一些完成 file upload 的基础 API. 很多项目我们需要上传文件. 有简单的 input file, 有需要验证的,有需要压缩的(img),有需要分段的(video),有需要 ...
- Xamarin.Forms App Settings
配合James Montemagno的Component [Settings Plugin],实现Xamarin.Forms的设置. 更新系统配置且不需要进行重启app. 方式一xml Xamarin ...
- ubuntu下编译时遇到的错误及解决方式
1.错误展示: hangma@ubuntu:~/test/test/protest/stack_test$ gcc -c my_stack.c -o my_stack.o In file inclu ...
- 几年前再用exjts4,如今extjs5发布了,技术更新快,每次给人惊喜
我们非常高兴的宣布,Sencha Ext JS 5 beta版本开始进行公测了.这个beta版本可以让你.我们Sencha社区来对我们的Ext JS 5的工作进度进行评测.对于所以Ext JS开发人员 ...
- COJ 0557 4013多重部分和问题
4013多重部分和问题 难度级别:B: 运行时间限制:2000ms: 运行空间限制:262144KB: 代码长度限制:2000000B 试题描述 n种大小不同的数字 Ai,每种各Mi个,判断是否可以从 ...
- POJ1743---Musical Theme (后缀数组+二分)
题意 :求最长不相交重复子串的长度.. 可以先求出LCP,,对于长度 二分出答案..(竟然不会写二分) #include <set> #include <map> #inclu ...
- 远程连接mysql
win系统下,连接别人的mysql或者让别人链接自己的mysql: 打开命令行cmd 进入mysql: mysql -u root -p mysql>use mysql; mysql>s ...