matlab - 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?
解决方案
你必须能够用 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)
请注意,索引与数据向量分开存储。
推荐阅读
- android - Android studio报错:元素值常量表达式
- python - 对于尺寸为 1 的维度 0,索引 1 超出范围
- shell - 从 shell 脚本将变量传递给 snmptrap 命令
- kubernetes - Kubernetes - pod重新启动时触发作业
- machine-learning - imblearn 管道框架中的数据预处理步骤
- unity3d - Unity 中代码生成的自动化
- python - 如何根据数据框中的行求和找到第一个结果?
- pine-script - Pinescript 不允许在回测中做多和做空,但是 live 呢?
- python - 微秒数据.. 循环,'每 15 分钟间隔"
- azure-data-factory - Synapse/数据工厂 Sharepoint 在线列表连接器