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

Fix for cosine distance #4

Open
Kaeseknacker opened this issue Jul 23, 2021 · 0 comments
Open

Fix for cosine distance #4

Kaeseknacker opened this issue Jul 23, 2021 · 0 comments

Comments

@Kaeseknacker
Copy link

_cosine_distance implementation is incomplete (normalization is missing).

Can be fixed with these lines of code:

Eigen::MatrixXf NearNeighborDisMetric::_cosine_distance(const FEATURESS& x, const FEATURESS& y, bool data_is_normalized) {
    FEATURESS a = x;
    FEATURESS b = y;
    if (!data_is_normalized)
    {
        a.rowwise().normalize();
        b.rowwise().normalize();
    }
    MatrixXf res = 1. - (a*b.transpose()).array();
    return res;
}
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

1 participant