Skip to content

Commit 811f3d0

Browse files
committed
Embedding Projector: perform consistent knn calculation
1 parent b72d751 commit 811f3d0

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

+6-14
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
/** Maximum sample size for each projection type. */
9191
export const TSNE_SAMPLE_SIZE = 10000;
9292
export const UMAP_SAMPLE_SIZE = 5000;
@@ -470,23 +470,15 @@ export class DataSet {
470470
.map((neighbors) => neighbors.slice(0, nNeighbors))
471471
);
472472
} else {
473-
const knnGpuEnabled = (await util.hasWebGLSupport()) && !IS_FIREFOX;
474473
const numKnnNeighborsToCompute = Math.max(
475474
nNeighbors,
476475
MIN_NUM_KNN_NEIGHBORS
477476
);
478-
const result = await (knnGpuEnabled
479-
? knn.findKNNGPUCosDistNorm(
480-
data,
481-
numKnnNeighborsToCompute,
482-
(d) => d.vector
483-
)
484-
: knn.findKNN(
485-
data,
486-
numKnnNeighborsToCompute,
487-
(d) => d.vector,
488-
(a, b) => vector.cosDistNorm(a, b)
489-
));
477+
const result = await knn.findKNNGPUCosDistNorm(
478+
data,
479+
numKnnNeighborsToCompute,
480+
(d) => d.vector
481+
);
490482
this.nearest = result;
491483
return Promise.resolve(
492484
result.map((neighbors) => neighbors.slice(0, nNeighbors))

0 commit comments

Comments
 (0)