UFLDL教程练习(exercise)答案(2)
主成分分析与白化,这部分很简单,当然,其实是用Matlab比较简单,要是自己写SVD分解算法,足够研究好几个月的了。下面是我自己实现的练习答案,不保证完全正确,不过结果和网站上面给出的基本一致。
1.PCA in 2D
1.1 Step 1a: Implement PCA to obtain U
u = zeros(size(x, )); % You need to compute this
sigma = x * x' / size(x, 2);
[u,s,v]=svd(sigma);
1.2 Step 1b: Compute xRot, the projection on to the eigenbasis
xRot = zeros(size(x)); % You need to compute this
xRot=u'*x;
1.3 Step 2: Reduce the number of dimensions from 2 to 1.
k = ; % Use k = and project the data onto the first eigenbasis
xHat = zeros(size(x)); % You need to compute this
x_ap=u(:,:k)'*x;
xHat(:k,:)=x_ap;
xHat=u*xHat;
1.4 Step 3: PCA Whitening
xPCAWhite = zeros(size(x)); % You need to compute this
xPCAWhite = diag(./sqrt(diag(s) + epsilon)) * u' * x;
1.5 Step 3: ZCA Whitening
xZCAWhite = zeros(size(x)); % You need to compute this
xZCAWhite=u * diag(./sqrt(diag(s) + epsilon)) * u' * x;
2.PCA and Whitening
2.1 Step 0b: Zero-mean the data (by row)
avg = mean(x, );
x = x - repmat(avg, size(x, ), );
2.2 Step 1a: Implement PCA to obtain xRot
xRot = zeros(size(x)); % You need to compute this
sigma = x * x' / size(x, 2);
[U,S,V]=svd(sigma);
xRot=U'*x;
2.3 Step 1b: Check your implementation of PCA
covar = zeros(size(x, )); % You need to compute this
covar = xRot * xRot' / size(xRot, 2);
2.4 Step 2: Find k, the number of components to retain
k = ; % Set k accordingly
sum_k=;
sum=trace(S);
for k=:size(S,)
sum_k=sum_k+S(k,k);
if(sum_k/sum>=0.99) %0.9
break;
end
end
2.5 Step 3: Implement PCA with dimension reduction
xHat = zeros(size(x)); % You need to compute this
xTilde = U(:,:k)' * x;
xHat(:k,:)=xTilde;
xHat=U*xHat;
2.6 Step 4a: Implement PCA with whitening and regularisation
xPCAWhite = diag(./sqrt(diag(S) + epsilon)) * U' * x;
2.7 Step 4b: Check your implementation of PCA whitening
covar = zeros(size(xPCAWhite, ));
covar = xPCAWhite * xPCAWhite' / size(xPCAWhite, 2);
2.8 Step 5: Implement ZCA whitening
xZCAWhite=U * diag(./sqrt(diag(S) + epsilon)) * U' * x;
UFLDL教程练习(exercise)答案(2)的更多相关文章
- UFLDL教程笔记及练习答案二(预处理:主成分分析和白化)
首先将本节主要内容记录下来.然后给出课后习题的答案. 笔记: :首先我想推导用SVD求解PCA的合理性. PCA原理:如果样本数据X∈Rm×n.当中m是样本数量,n是样本的维数.PCA降维的目的就是为 ...
- Deep Learning 10_深度学习UFLDL教程:Convolution and Pooling_exercise(斯坦福大学深度学习教程)
前言 理论知识:UFLDL教程和http://www.cnblogs.com/tornadomeet/archive/2013/04/09/3009830.html 实验环境:win7, matlab ...
- Deep Learning 19_深度学习UFLDL教程:Convolutional Neural Network_Exercise(斯坦福大学深度学习教程)
理论知识:Optimization: Stochastic Gradient Descent和Convolutional Neural Network CNN卷积神经网络推导和实现.Deep lear ...
- Deep Learning 13_深度学习UFLDL教程:Independent Component Analysis_Exercise(斯坦福大学深度学习教程)
前言 理论知识:UFLDL教程.Deep learning:三十三(ICA模型).Deep learning:三十九(ICA模型练习) 实验环境:win7, matlab2015b,16G内存,2T机 ...
- Deep Learning 12_深度学习UFLDL教程:Sparse Coding_exercise(斯坦福大学深度学习教程)
前言 理论知识:UFLDL教程.Deep learning:二十六(Sparse coding简单理解).Deep learning:二十七(Sparse coding中关于矩阵的范数求导).Deep ...
- Deep Learning 11_深度学习UFLDL教程:数据预处理(斯坦福大学深度学习教程)
理论知识:UFLDL数据预处理和http://www.cnblogs.com/tornadomeet/archive/2013/04/20/3033149.html 数据预处理是深度学习中非常重要的一 ...
- Deep Learning 9_深度学习UFLDL教程:linear decoder_exercise(斯坦福大学深度学习教程)
前言 实验内容:Exercise:Learning color features with Sparse Autoencoders.即:利用线性解码器,从100000张8*8的RGB图像块中提取颜色特 ...
- Deep Learning 8_深度学习UFLDL教程:Stacked Autocoders and Implement deep networks for digit classification_Exercise(斯坦福大学深度学习教程)
前言 1.理论知识:UFLDL教程.Deep learning:十六(deep networks) 2.实验环境:win7, matlab2015b,16G内存,2T硬盘 3.实验内容:Exercis ...
- Deep Learning 7_深度学习UFLDL教程:Self-Taught Learning_Exercise(斯坦福大学深度学习教程)
前言 理论知识:自我学习 练习环境:win7, matlab2015b,16G内存,2T硬盘 练习内容及步骤:Exercise:Self-Taught Learning.具体如下: 一是用29404个 ...
- Deep Learning 5_深度学习UFLDL教程:PCA and Whitening_Exercise(斯坦福大学深度学习教程)
前言 本文是基于Exercise:PCA and Whitening的练习. 理论知识见:UFLDL教程. 实验内容:从10张512*512自然图像中随机选取10000个12*12的图像块(patch ...
随机推荐
- Spark Streaming 执行流程
Spark Streaming 是基于spark的流式批处理引擎,其基本原理是把输入数据以某一时间间隔批量的处理,当批处理间隔缩短到秒级时,便可以用于处理实时数据流. 本节描述了Spark Strea ...
- 如何在Linux下Redis安装
转载出于:http://blog.csdn.net/jiangguilong2000/article/details/8114740 redis作为NoSQL数据库的一种应用,响应速度和命中率上还是比 ...
- .net类中静态方法的继承
父类中的静态方法,继承的子类能不能调用?一直在这里有疑惑,即使在下面的测试之后,也只是得到了结论,不明原理. class ClsParent { public static void ShowSth( ...
- @Resource、@Autowired跟default-autowire区别联系
@Resource.@Autowired和default-autowire区别联系 今天看了一工程,里面既有default-autowire,又有@Autowired,还有@Resource.我就不明 ...
- 在ASP.NET CORE下生成PDF文档
原文链接:https://www.c-sharpcorner.com/article/creating-pdf-in-asp-net-core-mvc-using-rotativa-aspnetcor ...
- Androidn Notification的使用,解决找不到setLatestEventInfo方法
转自:http://blog.csdn.net/songyachao/article/details/51245370#comments 今天使用4.0.3使用 Notification notifi ...
- TP Rate ,FP Rate, Precision, Recall, F-Measure, ROC Area,
TP Rate ,FP Rate, Precision, Recall, F-Measure, ROC Area, https://www.zhihu.com/question/30643044 T/ ...
- hash模块 hashlib不可逆加密 和 base64算法加密解密
hashlib模块 用于加密相关的操作,代替md5模块和sha模块,主要提供SHA1,SHA224,SSHA256,SHA384,SHA512,MD5算法 直接看代码案例: ---------md5- ...
- mysql查询常用小语句
mysql 查询某个库里表的数量 在mysql中有个数据库information_schema下的表tables记录了所有数据库中所有的表相关信息 TABLE_SCHEMA 数据库名称 SELECT ...
- 车小米O2O保养平台搭建完毕
www.51chexiaomi.com 无忧车小米上线了,开展上海地区的试运营