UFLDL教程Exercise答案(3.1):PCA in 2D
2016-11-21 13:07
381 查看
教程地址:http://deeplearning.stanford.edu/wiki/index.php/UFLDL_Tutorial
Exercise地址:http://deeplearning.stanford.edu/wiki/index.php/Exercise:PCA_in_2D
Exercise地址:http://deeplearning.stanford.edu/wiki/index.php/Exercise:PCA_in_2D
代码
Step 1a: Implement PCA to obtain U
u = zeros(size(x, 1)); % You need to compute this sigma = x * x' / size(x,2); %计算协方差矩阵sigma;x 是一个n*m的矩阵,每列表示一个训练样本 [u,s,v] = svd(sigma); %矩阵 U 将包含 Sigma 的特征向量(一个特征向量一列,从主向量开始排序), %矩阵S 对角线上的元素将包含对应的特征值(同样降序排列)。 %矩阵v等于u的转置,可以忽略
Step 1b: Compute xRot, the projection on to the eigenbasis
xRot = zeros(size(x)); % You need to compute this xRot = u' * x;
Step 2: Reduce the number of dimensions from 2 to 1.
k = 1; % Use k = 1 and project the data onto the first eigenbasis xHat = zeros(size(x)); % You need to compute this xTlide = zeros(size(x)); xTlide(1:k,:) = u(:,1:k)' * x; %数据降维后的结果,k为希望保留的特征向量的数目 xHat = u * xTlide; %还原近似数据
Step 3: PCA Whitening
xPCAWhite = zeros(size(x)); % You need to compute this xPCAWhite = diag(1./sqrt(diag(s) + epsilon)) * u' * x;
Step 3: ZCA Whitening
xZCAWhite = zeros(size(x)); % You need to compute this xZCAWhite = u * diag(1./sqrt(diag(s) + epsilon)) * u' * x;
相关文章推荐
- UFLDL教程答案(3):Exercise:PCA_in_2D&PCA_and_Whitening
- Deep Learning 4_深度学习UFLDL教程:PCA in 2D_Exercise(斯坦福大学深度学习教程)
- Python数据处理 PCA/ZCA 白化(UFLDL教程:Exercise:PCA_in_2D&PCA_and_Whitening)
- UFLDL教程:Exercise:PCA in 2D & PCA and Whitening
- Stanford UFLDL教程 Exercise:PCA in 2D
- UFLDL教程Exercise答案(3.2):PCA and Whitening
- UFLDL——Exercise: PCA in 2D 主成分分析
- UFLDL教程 Exercise:Vectorization(答案)
- UFLDL教程Exercise答案(2):Vectorization
- UFLDL教程答案(8):Exercise:Convolution and Pooling
- UFLDL教程答案(7):Exercise:Learning color features with Sparse Autoencoders
- UFLDL教程Exercise答案(8):Convolution and Pooling
- UFLDL教程 Exercise:Sparse Autoencoder(答案)
- UFLDL教程Exercise答案(5):Self-Taught Learning
- UFLDL教程Exercise答案(4):Softmax Regression
- UFLDL教程Exercise答案(1):Sparse Autoencoder
- UFLDL教程之(三)PCA and Whitening exercise
- UFLDL教程练习(exercise)答案(2)
- 【DeepLearning】Exercise:PCA in 2D
- UFLDL教程答案(1):Exercise:Sparse_Autoencoder