Skip to content

Commit b93909b

Browse files
authored
Upgrade six node-based examples (#366)
Upgrade the following examples to tfjs 1.7.4: - date-conversion-attention - fashion-mnist - mnist-acgan - sentiment - snake-dqn Full upgrade to 2.6.0 is blocked in these examples due to ES6 module changes in tfjs, which breaks the unit tests. This issue will be addressed later. Upgrade the following example to tfjs 2.6.0: - simple-object-detection (This example doesn't have unit tests yet.) In addition, in the date-conversion-attention example, fix a bug in the sorting of the x- and y-label ticks that causes the rows and columns of the attention matrix to go out of order. All six examples are tested manually to ensure that they continue to work.
1 parent 4c0f639 commit b93909b

File tree

13 files changed

+7302
-4601
lines changed

13 files changed

+7302
-4601
lines changed

date-conversion-attention/index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ inputDateString.addEventListener('change', async () => {
6060
status.textContent = `seq2seq conversion took ${tElapsed.toFixed(1)} ms`;
6161
outputDateString.value = outputStr;
6262

63-
const xTickLabels =
64-
outputStr.split('').map((char, i) => `(${i + 1}) "${char}"`);
63+
const xTickLabels = outputStr.split('').map(
64+
(char, i) => `(${integerToTwoDigitString(i + 1)}) "${char}"`);
6565
const yTickLabels = [];
6666
for (let i = 0; i < INPUT_LENGTH; ++i) {
6767
if (i < inputStr.length) {
68-
yTickLabels.push(`(${i + 1}) "${inputStr[i]}"`);
68+
yTickLabels.push(`(${integerToTwoDigitString(i + 1)}) "${inputStr[i]}"`);
6969
} else {
70-
yTickLabels.push(`(${i + 1}) ""`);
70+
yTickLabels.push(`(${integerToTwoDigitString(i + 1)}) ""`);
7171
}
7272
}
7373
await tfvis.render.heatmap(
@@ -94,6 +94,11 @@ randomButton.addEventListener('click', async () => {
9494
inputDateString.dispatchEvent(new Event('change'));
9595
});
9696

97+
function integerToTwoDigitString(x) {
98+
const str = `${x / 100}`.substr(2);
99+
return str.length == 1 ? str + '0' : str;
100+
}
101+
97102
async function init() {
98103
try {
99104
status.textContent = `Loading model from ${RELATIVE_MODEL_URL} ...`;

date-conversion-attention/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"watch": "cross-env NODE_ENV=development parcel index.html --no-hmr --open"
1616
},
1717
"dependencies": {
18-
"@tensorflow/tfjs": "^1.3.2",
19-
"@tensorflow/tfjs-vis": "1.0.3"
18+
"@tensorflow/tfjs": "^1.7.4",
19+
"@tensorflow/tfjs-vis": "^1.4.3"
2020
},
2121
"devDependencies": {
22-
"@tensorflow/tfjs-node": "^1.3.2",
23-
"@tensorflow/tfjs-node-gpu": "^1.3.2",
22+
"@tensorflow/tfjs-node": "^1.7.4",
23+
"@tensorflow/tfjs-node-gpu": "^1.7.4",
2424
"argparse": "^1.0.10",
2525
"babel-cli": "^6.26.0",
2626
"babel-core": "^6.26.3",

date-conversion-attention/yarn.lock

+777-457
Large diffs are not rendered by default.

fashion-mnist-vae/package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
"node": ">=8.11.0"
1010
},
1111
"dependencies": {
12-
"@tensorflow/tfjs": "^1.3.2",
13-
"@tensorflow/tfjs-node": "^1.3.2",
14-
"@tensorflow/tfjs-node-gpu": "^1.3.2",
15-
"@tensorflow/tfjs-vis": "^1.0.3",
12+
"@tensorflow/tfjs": "^1.7.4",
13+
"@tensorflow/tfjs-node": "^1.7.4",
14+
"@tensorflow/tfjs-node-gpu": "^1.7.4",
15+
"@tensorflow/tfjs-vis": "^1.4.3",
1616
"argparse": "^1.0.10",
1717
"d3-selection": "^1.4.0",
1818
"http-server": "^0.11.1",

0 commit comments

Comments
 (0)