This file contains hidden or 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 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(); |
This file contains hidden or 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
// 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( |