Skip to content

Commit 5bd37ea

Browse files
committed
Embedding Projector: perform consistent knn calculation
1 parent e5d1771 commit 5bd37ea

File tree

1 file changed

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

1 file changed

+6
-10
lines changed

tensorboard/plugins/projector/vz_projector/data.ts

+6-10
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;
@@ -473,15 +473,11 @@ export class DataSet {
473473
.map((neighbors) => neighbors.slice(0, nNeighbors))
474474
);
475475
} else {
476-
const knnGpuEnabled = (await util.hasWebGLSupport()) && !IS_FIREFOX;
477-
const result = await (knnGpuEnabled
478-
? knn.findKNNGPUCosDistNorm(data, nNeighbors, (d) => d.vector)
479-
: knn.findKNN(
480-
data,
481-
nNeighbors,
482-
(d) => d.vector,
483-
(a, b) => vector.cosDistNorm(a, b)
484-
));
476+
const result = await knn.findKNNGPUCosDistNorm(
477+
data,
478+
nNeighbors,
479+
(d) => d.vector
480+
);
485481
this.nearest = result;
486482
return Promise.resolve(result);
487483
}

0 commit comments

Comments
 (0)