Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilyReif committed Feb 13, 2019
1 parent 2c614b9 commit d3d00b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions visualization/visualization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ export class Visualization {
const targetLoc = (axesWidth / WIDTH) * bias;

// Spring force toward the target location, (in %.)
const pull = (targetLoc - pos.x / (WIDTH / 2)) / 2;
const springForceK = 2;
const pull = (targetLoc - pos.x / (WIDTH / 2)) / springForceK;

// Caluclate and set the new position.
const posVel =
Expand Down Expand Up @@ -471,9 +472,11 @@ export class Visualization {
// Bounce is less high for words, cause it looks pretty annoying.
let vBounce;
if (!isRain) {
vBounce = 1 / 100 + Math.random() / 10;
const bounceDampener = 10;
vBounce = 1 / 100 + Math.random() / bounceDampener;
} else {
vBounce = -v * Math.random() / 3;
const bounceDampener = 3;
vBounce = -v * Math.random() / bounceDampener;
}

// Figure out if we're near a word axis, and bounce if so.
Expand Down
4 changes: 4 additions & 0 deletions word_embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export class WordEmbedding {
});
}

/**
* Project all words along the axes to precompute the biases.
* @param axes axes along which to project all words.
*/
computeProjections(axes: string[][]): tf.Tensor {
return tf.tidy(() => {
// Collect the directions for each axis.
Expand Down

0 comments on commit d3d00b9

Please sign in to comment.