Skip to content

Conversation

@TimoSci
Copy link
Contributor

@TimoSci TimoSci commented Dec 12, 2019

The visual function, which finds the winner neuron for an arbitrary "specimen" input, was using a brute force search to find the nearest neighbor among the neuron codes.

A k-d tree search is usually faster than a brute force search, especially when doing a large number of queries over a large number of neurons.

The disadvantage of a k-d tree is that the initial construction of the tree is costly, but once constructed, search queries are fast. That's why we can't use the k-d tree in the training algorithm - we would have to reconstruct after every step.

But for functions on an already-trained SOM, like mapToSOM, a k-d tree can be advantageous, in most practical use cases.

Example of a benchmark I have done

In this PR I suggest including an optimized version of the visual function.

PS. Caching the k-d tree in the SOM struct might also be a good idea.

@TimoSci TimoSci closed this Dec 15, 2019
@TimoSci
Copy link
Contributor Author

TimoSci commented Dec 15, 2019

This pull request was replaced with a new one (#19) after some refactoring and inclusion of a test.

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

Successfully merging this pull request may close these issues.

1 participant