Skip to content

Instantly share code, notes, and snippets.

@alseambusher
Created January 23, 2018 22:28
Show Gist options
  • Save alseambusher/8694ad1eefbc68fd0082192958681c63 to your computer and use it in GitHub Desktop.
Save alseambusher/8694ad1eefbc68fd0082192958681c63 to your computer and use it in GitHub Desktop.
flatten deeplearn.js
/**
* Flattens an input tensor.
* @param inputs Tensor input
*/
function flatten(inputs: Tensor) {
return g.reshape(inputs, (() => {
let i = 1;
inputs.shape.forEach((val) => { i *= val });
return [i];
})());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment