Skip to content

Commit d1c504f

Browse files
authored
Embedding Projector: update tsne learning rate during iteration (#6319)
## Motivation for features / changes #6289 ## Technical description of changes new tsne learning rate will take effect during next tsne iteration ## Screenshots of UI changes N/A ## Detailed steps to verify changes work correctly (as executed by you) 1. Open t-SNE projection 1. Adjust learning rate 1. Verify a small learning rate will stall changes and a large learning rate will accelerate changes between iterations ## Alternate designs / implementations considered
1 parent a1a3b14 commit d1c504f

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

tensorboard/plugins/projector/vz_projector/bh_tsne.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export class TSNE {
259259
constructor(opt: TSNEOptions) {
260260
opt = opt || {dim: 2};
261261
this.perplexity = opt.perplexity || 30;
262-
this.epsilon = opt.epsilon || 10;
262+
this.setEpsilon(opt.epsilon || 10);
263263
this.rng = opt.rng || Math.random;
264264
this.dim = opt.dim;
265265
if (opt.dim === 2) {
@@ -383,6 +383,9 @@ export class TSNE {
383383
}
384384
}
385385
}
386+
setEpsilon(epsilon: number) {
387+
this.epsilon = epsilon;
388+
}
386389
setSupervision(superviseLabels: string[], superviseInput?: string) {
387390
if (superviseLabels != null) {
388391
this.labels = superviseLabels;

tensorboard/plugins/projector/vz_projector/data.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ export class DataSet {
503503
});
504504
}
505505
}
506+
setTsneLearningRate(learningRate: number) {
507+
if (this.tsne) {
508+
this.tsne.setEpsilon(learningRate);
509+
}
510+
}
506511
setSupervision(superviseColumn: string, superviseInput?: string) {
507512
if (superviseColumn != null) {
508513
this.superviseLabels = this.shuffledDataIndices

tensorboard/plugins/projector/vz_projector/vz-projector-projections-panel.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ class ProjectionsPanel extends LegacyElementMixin(PolymerElement) {
161161
private updateTSNELearningRateFromUIChange() {
162162
if (this.learningRateInput) {
163163
this.learningRate = Math.pow(10, +this.learningRateInput.value);
164+
if (this.dataSet) {
165+
this.dataSet.setTsneLearningRate(this.learningRate);
166+
}
164167
}
165168
(this.$$('.tsne-learning-rate span') as HTMLSpanElement).innerText =
166169
'' + this.learningRate;

0 commit comments

Comments
 (0)