Skip to content

Instantly share code, notes, and snippets.

@N8python
Created October 29, 2020 17:03
Show Gist options
  • Save N8python/579138a64e516f960c2d9dbd4a7df5b3 to your computer and use it in GitHub Desktop.
Save N8python/579138a64e516f960c2d9dbd4a7df5b3 to your computer and use it in GitHub Desktop.
(async() => {
const model = await tf.loadLayersModel('file://./encoder-model/model.json');
const input = tf.input({ shape: [2] });
const dense1 = model.layers[4].apply(input);
const dense2 = model.layers[5].apply(dense1);
const dense3 = model.layers[6].apply(dense2);
const dense4 = model.layers[7].apply(dense3);
const decoder = tf.model({ inputs: input, outputs: dense4 });
await decoder.save(`file://./decoder-model`);
mnistToImage(decoder.predict(tf.tensor([
[0.3, -0.5]
])).dataSync().map(x => x * 255)).pack().pipe(fs.createWriteStream(`plzwork.png`));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment