Last active
March 24, 2019 13:42
-
-
Save NMZivkovic/557c06e3f3159df2b0ded4d996bacdb3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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