Skip to content

Instantly share code, notes, and snippets.

View generic-github-user's full-sized avatar
📚
fervently skimming arXiv

Anna Allen generic-github-user

📚
fervently skimming arXiv
  • United States
View GitHub Profile
@generic-github-user
generic-github-user / script.js
Last active February 3, 2019 01:18
Checking how many elements match in two tensors
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 October 9, 2018 10:47
Converting a string to and from a one-hot encoded binary vector
// 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 September 27, 2018 10:29
Accessing internal weight values of a TensorFlow.js model
We couldn’t find that file to show.