MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / constructor

Method constructor

addition-rnn-webworker/worker.js:26–39  ·  view source on GitHub ↗

* Constructor of CharacterTable. * @param chars A string that contains the characters that can appear * in the input.

(chars)

Source from the content-addressed store, hash-verified

24 * in the input.
25 */
26 constructor(chars) {
27 this.chars = chars;
28 this.charIndices = {};
29 this.indicesChar = {};
30 this.size = this.chars.length;
31 for (let i = 0; i < this.size; ++i) {
32 const char = this.chars[i];
33 if (this.charIndices[char] != null) {
34 throw new Error(`Duplicate character '${char}'`);
35 }
36 this.charIndices[this.chars[i]] = i;
37 this.indicesChar[i] = this.chars[i];
38 }
39 }
40
41 /**
42 * Convert a string into a one-hot encoded tensor.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected