Question-1
Use https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz MNIST
dataset for this question and perform following tasks.
• It has all in all 60K train samples from 10 classes and 10K test samples.
10 classes are digits from 0-9. Labels or classes for all samples in train
and test set is available.
• Visualize 5 samples from each class in the train set in form of images.
• Images are of size 28×28. Vectorize them to make it 784 dimensional.
Apply QDA on the given dataset. For each of the 10 classes you need to
compute its mean vector and covariance vector. Use the QDA expression
derived in the lecture. Your code should clearly have this expression. Note
mean and covariance will be computed from train set only. Test set is not
seen at this stage.
• Find the class of all samples in test set. Report accuracy and class-wise
accuracy for testing dataset. Accuracy is ratio of total number of samples
correctly classified to the total number of samples tested. Total number of
samples tested is 10K. Similarly, for each class report the accuracy. Note
the labels or classes for each sample is given in the dataset.
1
3 Question-2
Use same downloaded dataset from Question 1 and perform following tasks.
• Choose 100 samples from each class and create a 784×1000 data matrix.
Let this be X.
• Remove mean from X.
• Apply PCA on the centralized X. You need to compute covariance S =
XX>/999. The find its eigenvectors and eigenvalues. You can use any
library for this. Sort them in descending order and create matrix U.
• Perform Y = U
>X and reconstruct Xrecon = UY . Check the MSE between X and Xrecon. This should be close to 0. MSE = P
i,j (X(i, j) −
Xrecon(i, j))2
.
• Now chose p = 5, 10, 20 eigenvectors from U. For each p, obtain UpY , add
mean that was removed from X, reshape each column to 28×28, and plot
the image. You should see that as p increase the reconstructed images
look more like their original counterparts. Plot 5 images from each class.
• Let test set be Xtest. Find Y = U
>
p Xtest. For each value of p find Y , and
apply QDA from Q1 on Y. Obtain accuracy on test set as well as per class
accuracy. As p inreases, accuracy shall increase.
Assignment, CSE342, solved
[SOLVED] Cse342 sml assignment 2
$25
File Name: Cse342_sml_assignment_2.zip
File Size: 216.66 KB
Only logged in customers who have purchased this product may leave a review.
Reviews
There are no reviews yet.