Starting from:

$30

CSE512 Homework 6 Solved

PCA via Successive Deflation [30 points]
Suppose we have a set of n data points x1,...,xn, where each xi is represented as a d-dimensional column vector. Assume that the data has been centerlized, i.e., having zero mean: . Let X = [x1;...;xn] be the (d × n) matrix where column i is equal to xi. Define C to be the covariance matrix of X, where .

Next, order the eigenvectors of C by their eigenvalues (largest first), and let v1,v2,...,vk be the first k eigenvectors. These satisfy



v1 is the first principal eigenvector of C (the eigenvector with the largest eigenvalue), and as such satisfies Cv1 = λ1v1. Now define x˜i as the orthogonal projection of xi onto the space orthogonal to v1:



Finally, define X˜ = [x˜1;...;x˜n] as the deflated matrix of rank d − 1, which is obtained by removing from the d-dimensional data the component that lies in the direction of the first principal eigenvector:

X˜ X

1.    [7 points] Show that the covariance of the deflated matrix,

                                                                                                  C˜ 1X˜X˜ T

is given by

                                                                                       C˜ 1v1v1

(Hint: Some useful facts:  is symmetric, XXTv1 = nλ1v1, and v . Also, for any matrices A and B, (AB)T = BTAT.)

2.    [7 points] Show that for j 6= 1, if vj is a principal eigenvector of C with corresponding eigenvalue λj (that is, Cvj = λjvj), then vj is also a principal eigenvector of C˜ with the same eigenvalue λj.

3.    [8 points] Let u be the first principal eigenvector of C˜. Explain why u = v2. (You may assume u is unit norm.)

4.    [8 points] Suppose we have a simple method f for finding the leading eigenvector and eigenvalue of a positive-definite matrix, denoted by [λ,u] = f(C). Write some pseudocode for finding the first k principal basis vectors of X that only uses the special f function and simple vector arithmetic.

(Hint: This should be a simple iterative routine that takes only a few lines to write. The input is C,k, and the function f, the output should be vj and λj for j ∈ 1,··· ,k)

2         Action recognition with CNN (35 points + 10 bonus)
In this question, you will train a convolutional neural network (CNN) to classify images and videos using Pytorch. We use the UCF101 data (see http://crcv.ucf.edu/data/UCF101.php). There are also 10 classes of data in this homework but the data and the number of classes are different from those of Homework 4. Each clip has 3 frames and each frame is 64 ∗ 64 pixels. The labels of train and validation clips are provided in hw6 data.mat inside the directory Question2.

You will first train a CNN for action classification for each image. You will then improve the network architecture and submit the classification results on the test data to Kaggle. Then, you will train a CNN using 3D convolution for a set of video frames (rather than for individual frames), and submit your results to Kaggle.

The detail instructions and questions are in the jupyter notebook Action CNN.ipynb. In this file, there are 8 ‘ToDos’ spots for you to fill. The score of each ToDo is specified at the spot. For the 5th and 8th ToDos, you need to submit CSV result files to Kaggle. The results would be evaluated by Categorization Accuracy.For the 5th ToDo, submit to https://www.kaggle.com/c/cse512hw6image. For the 8th ToDo, submit to https://www.kaggle.com/c/cse512hw6video.

We will maintain a leader board for each Kaggle competition, and the top three entries at the end of the competition (official assignment due date) will receive 10 bonus points. Any submission that rises to top three after the assignment deadline is not eligible for bonus points. The ranking will be based on the Categorization Accuracy. Marks for these questions will be scaled according to the ranking on the Private Leaderboard. To prevent exploiting test data, you are allowed to make a maximum of 2 submissions per 24 hours. Your submission will be evaluated immediately and the leader board will be updated.

Environment setting

Please make a ./data folder under the same directory with the Action CNN.ipynb file. Put data trainClips, valClips, testClips and hw6 data.mat from the Question2 directory under ./data.

We recommend using virtual environment for the project. If you choose not to use a virtual environment, it is up to you to make sure that all dependencies for the code are installed globally on your machine. To set up a virtual environment, run the following in the command-line interface:

cd your_hw6_folder

sudo pip install virtualenv
# This may already be installed
virtualenv .env
# Create a virtual environment
source .env/bin/activate
# Activate the virtual environment
pip install -r requirements.txt # Install dependencies # Note that this does NOT install TensorFlow or PyTorch, # which you need to do yourself.

# Work (hard) on the assignment # ... and when you’re done:

deactivate                                                                                         # Exit the virtual environment

Note that every time you want to work on the assignment, you should run ‘source .env/bin/activate’ (from within your hw6 folder) to re-activate the virtual environment, and deactivate again whenever you are done.

3         Action Classification Using RNN (35 points)
In this section, you will train recurrent neural networks (RNNs) to classify human actions. RNNs are designed handle sequential data.

For human action recognition, you will be using skeleton data that encodes the 3D locations of 25 body joints. The data is collected by Kinect v2. There are 10 different action classes. There are 4000 training sequences, 800 validation sequences, and 1000 test sequences. Each sequence has 15 frames, each frame is a 75-dimension vector (the xyz positions of 25 joints). Data and the Jupyter notebook for this question are provided inside the directory Question3.

You will first train an LSTM for action classification. Then try to improve the network architecture and attach your results with the jupyter notebook. Also add the hyper-parameters explored.

The detailed instructions and questions are in the jupyter notebook RNN ActionClassify.ipynb. In this file, there are 4 ToDo locations for you to fill. The score of each ToDo is specified at the spot. You will need to install the following extra packages:

pip install h5py

More products