Skip to content

Commit

Permalink
public npm config and build (tensorflow#40)
Browse files Browse the repository at this point in the history
* update package.json and build targets for publishing
  • Loading branch information
tafsiri authored May 30, 2018
1 parent e3c07a9 commit 8b8c2f7
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 1,959 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package-lock.json
node_modules/
dist/
dist-es6/
coverage/
*.lock
.cache
Expand Down
7 changes: 4 additions & 3 deletions examples/script_tag/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

<head>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/[email protected]"> </script>
<script src="./tfjs-tsne.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-tsne"></script>

<script src="https://d3js.org/d3.v5.min.js"></script>
</head>

<body>
<h1>tfjs-tsne simple example</h1>
<p>Reduce 20000 points with 100 dimensions each. Open up the browser console to see progress while the embedding is being
computed.</p>
<script src="./index.js"></script>
computed.
</p>
<script src="./index.js" defer></script>
</body>

</html>
22 changes: 5 additions & 17 deletions examples/script_tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,8 @@ async function computeEmbedding(data, numPoints) {
// Note that this may take a while.
await embedder.compute(1000);

// Get the coordinates (in embedding space) of the data
const coordinates = await embedder.coordinates().data();

const coords = [];
for (let p = 0; p < numPoints; ++p) {
// TODO reshape this to a 2d array.
const x = coordinates[p * 2];
const y = coordinates[p * 2 + 1];
coords.push([x, y]);
}
return coords;
// Get the normalized coordinates of the data
return await embedder.coordsArray();
}

/**
Expand All @@ -84,11 +75,8 @@ function showEmbedding(data) {
const width = 800 - margin.left - margin.right;
const height = 800 - margin.top - margin.bottom;

const x =
d3.scaleLinear().domain(d3.extent(data, d => d[0])).range([0, width]);

const y =
d3.scaleLinear().domain(d3.extent(data, d => d[1])).range([height, 0]);
const x = d3.scaleLinear().domain([0, 1]).range([0, width]);
const y = d3.scaleLinear().domain([0, 1]).range([height, 0]);

const chart = d3.select('body')
.append('svg')
Expand Down Expand Up @@ -130,4 +118,4 @@ function showEmbedding(data) {
.attr('r', 5);
}

start();
document.addEventListener('DOMContentLoaded', () => start());
1,921 changes: 0 additions & 1,921 deletions examples/script_tag/tfjs-tsne.js

This file was deleted.

15 changes: 3 additions & 12 deletions examples/synthetic_data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,8 @@ async function computeEmbedding(data, numPoints) {
// Note that this may take a while.
await embedder.compute(1000);

// Get the coordinates (in embedding space) of the data
const coordinates = await embedder.coordinates().data();

const coords = [];
for (let p = 0; p < numPoints; ++p) {
// TODO reshape this to a 2d array.
const x = coordinates[p * 2];
const y = coordinates[p * 2 + 1];
coords.push([x, y]);
}
return coords;
// Get the normalized coordinates of the data
return await embedder.coordsArray();
}

/**
Expand Down Expand Up @@ -129,4 +120,4 @@ function showEmbedding(data) {
.attr('r', 5);
}

start();
document.addEventListener('DOMContentLoaded', () => start());
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"name": "tfjs-tsne",
"name": "@tensorflow/tfjs-tsne",
"version": "0.0.1",
"description": "TensorFlow.js powered tSNE implementation",
"private": true,
"private": false,
"main": "dist/index.js",
"jsdelivr": "dist/tsne.min.js",
"unpkg": "dist/tsne.min.js",
"jsdelivr": "dist/tfjs-tsne.min.js",
"unpkg": "dist/tfjs-tsne.min.js",
"jsnext:main": "dist-es6/index.js",
"module": "dist-es6/index.js",
"types": "dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/tensorflow/tfjs-tsne.git"
},
"devDependencies": {
"@tensorflow/tfjs-core": "^0.10.1",
"clang-format": "~1.2.2",
Expand All @@ -32,7 +38,7 @@
"@tensorflow/tfjs-core": ">=0.10.1"
},
"scripts": {
"build": "tsc",
"build": "tsc --project tsconfig-es5.json && tsc",
"build-npm": "./scripts/build-npm.sh",
"link-local": "yalc link",
"publish-local": "yarn build-npm && yalc push",
Expand Down
7 changes: 7 additions & 0 deletions tsconfig-es5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "./dist"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"es2015",
"dom"
],
"outDir": "./dist",
"outDir": "./dist-es6",
"noUnusedLocals": true,
"noImplicitReturns": true,
"noImplicitThis": true,
Expand Down

0 comments on commit 8b8c2f7

Please sign in to comment.