Skip to content

[security] update all package.json for security patches #753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions addition-rnn-webworker/.babelrc

This file was deleted.

2 changes: 1 addition & 1 deletion addition-rnn-webworker/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,6 @@ <h1>TensorFlow.js: Addition RNN in web worker</h1>
</div>

</body>
<script src="./index.js">
<script type="module" src="index.js"></script>

</script>
69 changes: 40 additions & 29 deletions addition-rnn-webworker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
*/

import * as tfvis from '@tensorflow/tfjs-vis';
const worker = new Worker('./worker.js');
const worker =
new Worker(new URL('./worker.js', import.meta.url), {type: 'module'});

async function runAdditionRNNDemo() {
document.getElementById('trainModel').addEventListener('click', async () => {
const digits = +(document.getElementById('digits')).value;
const trainingSize = +(document.getElementById('trainingSize')).value;
const rnnTypeSelect = document.getElementById('rnnType');
const rnnType =
rnnTypeSelect.options[rnnTypeSelect.selectedIndex].getAttribute(
'value');
rnnTypeSelect.options[rnnTypeSelect.selectedIndex].getAttribute(
'value');
const layers = +(document.getElementById('rnnLayers')).value;
const hiddenSize = +(document.getElementById('rnnLayerSize')).value;
const batchSize = +(document.getElementById('batchSize')).value;
Expand All @@ -48,45 +49,55 @@ async function runAdditionRNNDemo() {
const trainingSizeLimit = Math.pow(Math.pow(10, digits), 2);
if (trainingSize > trainingSizeLimit) {
status.textContent =
`With digits = ${digits}, you cannot have more than ` +
`${trainingSizeLimit} examples`;
`With digits = ${digits}, you cannot have more than ` +
`${trainingSizeLimit} examples`;
return;
}
worker.postMessage({ digits, trainingSize, rnnType, layers, hiddenSize, trainIterations, batchSize, numTestExamples });
worker.postMessage({
digits,
trainingSize,
rnnType,
layers,
hiddenSize,
trainIterations,
batchSize,
numTestExamples
});
worker.addEventListener('message', (e) => {
if (e.data.isPredict) {
const { i, iterations, modelFitTime, lossValues, accuracyValues } = e.data;
const {i, iterations, modelFitTime, lossValues, accuracyValues} =
e.data;
document.getElementById('trainStatus').textContent =
`Iteration ${i + 1} of ${iterations}: ` +
`Time per iteration: ${modelFitTime.toFixed(3)} (seconds)`;
`Iteration ${i + 1} of ${iterations}: ` +
`Time per iteration: ${modelFitTime.toFixed(3)} (seconds)`;
const lossContainer = document.getElementById('lossChart');
tfvis.render.linechart(
lossContainer, { values: lossValues, series: ['train', 'validation'] },
{
width: 420,
height: 300,
xLabel: 'epoch',
yLabel: 'loss',
});
lossContainer,
{values: lossValues, series: ['train', 'validation']}, {
width: 420,
height: 300,
xLabel: 'epoch',
yLabel: 'loss',
});

const accuracyContainer = document.getElementById('accuracyChart');
tfvis.render.linechart(
accuracyContainer,
{ values: accuracyValues, series: ['train', 'validation'] }, {
width: 420,
height: 300,
xLabel: 'epoch',
yLabel: 'accuracy',
});
accuracyContainer,
{values: accuracyValues, series: ['train', 'validation']}, {
width: 420,
height: 300,
xLabel: 'epoch',
yLabel: 'accuracy',
});
} else {
const { isCorrect, examples } = e.data;
const {isCorrect, examples} = e.data;
const examplesDiv = document.getElementById('testExamples');
const examplesContent = examples.map(
(example, i) =>
`<div class="${
isCorrect[i] ? 'answer-correct' : 'answer-wrong'}">` +
`${example}` +
`</div>`);
(example, i) =>
`<div class="${
isCorrect[i] ? 'answer-correct' : 'answer-wrong'}">` +
`${example}` +
`</div>`);

examplesDiv.innerHTML = examplesContent.join('\n');
}
Expand Down
17 changes: 4 additions & 13 deletions addition-rnn-webworker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,15 @@
},
"scripts": {
"watch": "cross-env NODE_ENV=development parcel index.html --no-hmr --open",
"build": "cross-env NODE_ENV=production parcel build index.html --no-minify --public-url ./",
"build": "cross-env NODE_ENV=production parcel build index.html --public-url ./",
"link-local": "yalc link"
},
"devDependencies": {
"babel-core": "^6.26.3",
"babel-plugin-transform-runtime": "~6.23.0",
"babel-polyfill": "~6.26.0",
"babel-preset-env": "~1.6.1",
"buffer": "^6.0.3",
"clang-format": "~1.2.2",
"cross-env": "^5.1.6",
"parcel-bundler": "~1.12.5",
"parcel": "~2.3.2",
"process": "^0.11.10",
"yalc": "~1.0.0-pre.50"
},
"resolutions": {
"is-svg": "4.3.1",
"node-fetch": "2.6.1",
"vega": "5.17.3",
"glob-parent": "5.1.2",
"postcss": "8.2.10"
}
}
Loading