Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
async function singleImagePlot(image)
{
const canvas = document.createElement('canvas');
canvas.width = 28;
canvas.height = 28;
canvas.style = 'margin: 4px;';
await tf.browser.toPixels(image, canvas);
return canvas;
}
async function displayDataFunction(data, numOfImages = 10) {
const inputDataSurface =
tfvis.visor().surface({ name: 'Input Data Examples', tab: 'Input Data'});
const examples = data.nextDataBatch(numOfImages, true);
for (let i = 0; i < numOfImages; i++) {
const image = tf.tidy(() => {
return examples.xs
.slice([i, 0], [1, examples.xs.shape[1]])
.reshape([28, 28, 1]);
});
const canvas = await singleImagePlot(image)
inputDataSurface.drawArea.appendChild(canvas);
image.dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment