Question: Using this Matlab code: clear all; close all; % clear workspace websave('mnist.mat',https://github.com/daniel-e/mnist_octave/raw/master/mnist.mat); data=load('mnist.mat'); X = double(data.trainX); [N,D]=size(X); % visualising the first image in MNIST dataset
Using this Matlab code:
clear all; close all; % clear workspace
websave('mnist.mat',"https://github.com/daniel-e/mnist_octave/raw/master/mnist.mat");
data=load('mnist.mat');
X = double(data.trainX);
[N,D]=size(X);
% visualising the first image in MNIST dataset
figure;imagesc(reshape(X(1,:), 28, 28)'),colormap("gray")
% computing the mean image of MNIST dataset
MeanImage=mean(X,1);
figure;imagesc( reshape(MeanImage, 28, 28)'),colormap("gray")
% centering data
Xtilde=X-mean(X);
% covariance
S=Xtilde'*Xtilde/N;
[U,L,V]=svd(S);
% reconstruction of a test image
xtest = double(data.testX(1,:));
figure;imagesc(reshape(xtest, 28, 28)'),colormap("gray")
% reconstruction using #nbVector eigenvectors
nbVector=10;
Reconstruction = MeanImage+ ((xtest-MeanImage)*U(:,1:nbVector))*U(:,1:nbVector)';
figure;imagesc(reshape(Reconstruction, 28, 28)'),colormap("gray")
Question: What is the value of the highest eigenvalue? And how many principal components do we need to keep for reconstruction to get at least 90% of the variance explained?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
