首页 > 解决方案 > Matching PCA output to corresponding coordiantes

问题描述

I have this dataset consisting of around 800 images of the view of a car driving in circles with corresponding coordinates and changing background. The goal is to train a neural network to predict the position based on the images. I reshaped the images so that the original 160x320 pixels come down to 1x51200, so that I can feed my NN more easily. However, because this is a quite large dimension I applied a PCA to reduce the dimension and the PCA indeed worked well, so that I could only take the 100 eigenvectors with the highest eigenvalues and still have 90-95 % of the total variance.

But now comes my obstacle: I have these 100 images, still reconstructable and visualizable, but I don't exactly know, to which coordinates they correspond. I can't just take the first 100 coordinates because these eigenvalues where obviously taken from different timesteps through the progression of the images. I need this information so that my NN is able to match them while learning and checking its progress while testing. I read a similar question where the answers stated that it's not possible to extract indices out of a PCA-output, but I'm pretty sure there must be other persons who already faced similar obstacles?

标签: matlabmathneural-networkpcadimensionality-reduction

解决方案


你必须能够用 PCA 做什么才能从紧凑型到原始表示。

# dataset.shape = (800, 51200)
M = pca(dataset); # M.shape = (100, 51200)

original = dataset[k, :] # one vector corresponding to one image in your dataset
compressed_dataset = dataset @ M.T; # compressed_dataset.shape = (800, 100)

# if you have a compressed representation of an image you restore it with
restored = compressed_dataset[k, :] @ M # .shape = (1, 512000)

# here you expect all_close(restored, original)

请注意,索引与数据向量分开存储。


推荐阅读