Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于特征提取后进行feature_normalize的疑问 #3102

Open
yaphet266 opened this issue Mar 4, 2024 · 3 comments
Open

关于特征提取后进行feature_normalize的疑问 #3102

yaphet266 opened this issue Mar 4, 2024 · 3 comments
Assignees

Comments

@yaphet266
Copy link

在”特征提取“脚本中,看通过模型提取到特征向量后,对原有向量进行了feature_normalize操作得到新的特征向量,请问该操作作用是什么,是不是必须的

@cuicheng01
Copy link
Collaborator

这一步操作是必须的,因为在训练的时候使用了feature_normalize操作,所以在推理的时候也必须使用。另外,这里使用后,计算的相似度就不再是欧氏距离了,而是余弦距离。

@yaphet266
Copy link
Author

这一步操作是必须的,因为在训练的时候使用了feature_normalize操作,所以在推理的时候也必须使用。另外,这里使用后,计算的相似度就不再是欧氏距离了,而是余弦距离。

@cuicheng01 非常感谢你的回复。
你说的训练时候使用了feature_normalize是在GeneralRecognitionV2_PPLCNetV2_base.yaml文件这个位置吗
Loss:
Train:
- CELoss:
weight: 1.0
epsilon: 0.1
- TripletAngularMarginLoss:
weight: 1.0
feature_from: features
margin: 0.5
reduction: mean
add_absolute: True
absolute_loss_weight: 0.1
normalize_feature: True
ap_value: 0.8
an_value: 0.4
请问如果我指定了L2距离,计算相似度得到的也不再是欧式距离吗
这个向量相似度计算我自己实现有相关公式可以参考吗?

@changdazhou
Copy link
Contributor

可以去看看源码哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants