We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dbf6ea9 + 0c4d4fc commit a8acb08Copy full SHA for a8acb08
src/Word2vec/index.js
@@ -96,9 +96,9 @@ class Word2Vec {
96
97
static nearest(model, input, start, max) {
98
const nearestVectors = [];
99
- Object.keys(model).forEach((vector) => {
100
- const distance = tf.util.distSquared(input.dataSync(), model[vector].dataSync());
101
- nearestVectors.push({ vector, distance });
+ Object.keys(model).forEach((word) => {
+ const distance = tf.util.distSquared(input.dataSync(), model[word].dataSync());
+ nearestVectors.push({ word, distance });
102
});
103
nearestVectors.sort((a, b) => a.distance - b.distance);
104
return nearestVectors.slice(start, max);
0 commit comments