Skip to content

Instantly share code, notes, and snippets.

Avatar
📚
fervently skimming arXiv

Anna Allen generic-github-user

📚
fervently skimming arXiv
View GitHub Profile
@generic-github-user
generic-github-user / script.js
Last active Feb 3, 2019
Checking how many elements match in two tensors
View script.js
const a = tf.tensor1d([1,2,3,4,5,6,7]);
const b = tf.tensor1d([1,2,3,4,8,9,0]);
const matching = tf.equal(a, b).mean().mul(a.size);
matching.print();
@generic-github-user
generic-github-user / script.js
Last active Oct 9, 2018
Converting a string to and from a one-hot encoded binary vector
View script.js
// Converting a string to and from a one-hot encoded binary vector
// Accepts a string and returns an array of 1s and 0s
function encodeString(input, charset) {
// Define output as a variable containing an empty array
var output = [];
// Convert input string to array of all characters in input
input = input.split("");
// Loop through each character of the input string
input.forEach(
@generic-github-user
generic-github-user / script.js
Last active Sep 27, 2018
Accessing internal weight values of a TensorFlow.js model
We couldn’t find that file to show.