Skip to content

Instantly share code, notes, and snippets.

@Marina-Miranovich
Created November 14, 2018 20:43
Show Gist options
  • Save Marina-Miranovich/942951ca13e7219f22e366424f64a839 to your computer and use it in GitHub Desktop.
Save Marina-Miranovich/942951ca13e7219f22e366424f64a839 to your computer and use it in GitHub Desktop.
code_snippet_4 for "Playing Mortal Kombat with TensorFlow.js. Transfer learning and data augmentation" translation
const punches = require('fs')
.readdirSync(Punches)
.filter(f => f.endsWith('.jpg'))
.map(f => `${Punches}/${f}`);
const others = require('fs')
.readdirSync(Others)
.filter(f => f.endsWith('.jpg'))
.map(f => `${Others}/${f}`);
const ys = tf.tensor1d(
new Array(punches.length).fill(1)
.concat(new Array(others.length).fill(0)));
const xs: tf.Tensor2D = tf.stack(
punches
.map((path: string) => mobileNet(readInput(path)))
.concat(others.map((path: string) => mobileNet(readInput(path))))
) as tf.Tensor2D;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment