我正在尝试识别和分组相似的图像,我遵循了本教程:https ://douglasduhaime.com/posts/identifying-similar-images-with-tensorflow.html 。
问题是我使用的是faster_rcnn_resnet_101,我发现fast-rcnn中的特征向量在SecondStageBoxPredictor之后被丢弃了。我使用https://gist.github.com/markdtw/02ece6b90e75832bd44787c03a664e8d在被丢弃之前获取向量。
feat_avg = graph.get_tensor_by_name('SecondStageBoxPredictor/AvgPool:0')
np.savetxt('output1/' + "test" + '.npz',feat_vector,delimiter=',')
但是,当我尝试保存矢量时出现错误:
ValueError: Expected 1D or 2D array, got 4D array instead
我打印了提取的特征向量来查看结果:
Tensor("SecondStageFeatureExtractor/resnet_v1_101/block4/unit_3/bottleneck_v1/Relu:0", shape=(?, 7, 7, 2048), dtype=float32)
[[[[0. 0. 0. ... 0. 0.
0. ]
[0. 0. 0. ... 0. 0.
0. ]
[0. 0. 0. ... 0. 0.
0. ]
...
[2.9170244 0. 0.33220196 ... 0. 0.
0. ]
[0. 0. 0. ... 0. 0.
0. ]
[0. 0. 0. ... 0. 0.
0. ]].....
我是 TensorFlow 和 CV 的新手,我想做的是提取特征向量,然后使用 TSNE 聚类。我提取的特征向量到底有什么问题