比较两个2维特征向量以找出它们的相似性

问题描述

我试图比较两个特征向量的相似性。在激活中,形状输出为(60000,64),而new_activation的形状输出为(10000,64)。我正在寻找一种方法来找出new_activation中的向量与激活中的向量相似。我该怎么办?

预先感谢

#put all the the training data in the activation layer
activation = feature_activation_model.predict(train_img)

print(activation.shape)


#########

#put the new or old data to compare their feature vectors
new_activation = feature_activation_model.predict(test_img)

print(new_activation.shape)

解决方法

我猜这是python代码。

那么您需要找出相似向量的含义。在这里,您有60000个大小为64的矢量的表(激活时是行?),以及10000个大小为64的new_activation的矢量表。

我不知道您的数学问题在这里,所以我真的无济于事,但是向量之间的相似性可以定义为它们之间差异的范数。与|| u-v ||相比,令u和v为大小为n的向量。接近机器精度,我们可以将u和v设为几乎相同的向量