Created
November 14, 2018 20:43
-
-
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
This file contains 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
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