Skip to content

Commit 18cf7c5

Browse files
committed
Embedding Projector: perform consistent knn calculation
1 parent 4f0cd50 commit 18cf7c5

File tree

1 file changed

+6
-14
lines changed
  • tensorboard/plugins/projector/vz_projector

1 file changed

+6
-14
lines changed

tensorboard/plugins/projector/vz_projector/data.ts

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export interface DataPoint {
8686
[key: string]: number;
8787
};
8888
}
89-
const IS_FIREFOX = navigator.userAgent.toLowerCase().indexOf('firefox') >= 0;
89+
9090
/** Controls whether nearest neighbors computation is done on the GPU or CPU. */
9191
export const TSNE_SAMPLE_SIZE = 10000;
9292
export const UMAP_SAMPLE_SIZE = 5000;
@@ -475,23 +475,15 @@ export class DataSet {
475475
.map((neighbors) => neighbors.slice(0, nNeighbors))
476476
);
477477
} else {
478-
const knnGpuEnabled = (await util.hasWebGLSupport()) && !IS_FIREFOX;
479478
const numKnnNeighborsToCompute = Math.max(
480479
nNeighbors,
481480
MIN_NUM_KNN_NEIGHBORS
482481
);
483-
const result = await (knnGpuEnabled
484-
? knn.findKNNGPUCosDistNorm(
485-
data,
486-
numKnnNeighborsToCompute,
487-
(d) => d.vector
488-
)
489-
: knn.findKNN(
490-
data,
491-
numKnnNeighborsToCompute,
492-
(d) => d.vector,
493-
(a, b) => vector.cosDistNorm(a, b)
494-
));
482+
const result = await knn.findKNNGPUCosDistNorm(
483+
data,
484+
numKnnNeighborsToCompute,
485+
(d) => d.vector
486+
);
495487
this.nearest = result;
496488
return Promise.resolve(
497489
result.map((neighbors) => neighbors.slice(0, nNeighbors))

0 commit comments

Comments
 (0)