(strings, numRows)
| 60 | } |
| 61 | |
| 62 | encodeBatch(strings, numRows) { |
| 63 | const numExamples = strings.length; |
| 64 | const buf = tf.buffer([numExamples, numRows, this.size]); |
| 65 | for (let n = 0; n < numExamples; ++n) { |
| 66 | const str = strings[n]; |
| 67 | for (let i = 0; i < str.length; ++i) { |
| 68 | const char = str[i]; |
| 69 | if (this.charIndices[char] == null) { |
| 70 | throw new Error(`Unknown character: '${char}'`); |
| 71 | } |
| 72 | buf.set(1, n, i, this.charIndices[char]); |
| 73 | } |
| 74 | } |
| 75 | return buf.toTensor().as3D(numExamples, numRows, this.size); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * Convert a 2D tensor into a string with the CharacterTable's vocabulary. |
no outgoing calls
no test coverage detected