(dateStrings)
| 247 | * is the maximum possible input length of all valid input date-string formats. |
| 248 | */ |
| 249 | export function encodeInputDateStrings(dateStrings) { |
| 250 | const n = dateStrings.length; |
| 251 | const x = tf.buffer([n, INPUT_LENGTH], 'float32'); |
| 252 | for (let i = 0; i < n; ++i) { |
| 253 | for (let j = 0; j < INPUT_LENGTH; ++j) { |
| 254 | if (j < dateStrings[i].length) { |
| 255 | const char = dateStrings[i][j]; |
| 256 | const index = INPUT_VOCAB.indexOf(char); |
| 257 | if (index === -1) { |
| 258 | throw new Error(`Unknown char: ${char}`); |
| 259 | } |
| 260 | x.set(index, i, j); |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | return x.toTensor(); |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * Encode a number of output date strings as a `tf.Tensor`. |
nothing calls this directly
no outgoing calls
no test coverage detected