| 338 | } |
| 339 | |
| 340 | var check = function (which) { |
| 341 | // generate input from sequence |
| 342 | var input = []; |
| 343 | for (let j = 0; j < symbols; j++) |
| 344 | input[j] = 0; |
| 345 | input[sequence[which]] = 1; |
| 346 | |
| 347 | // generate target output |
| 348 | var output = []; |
| 349 | for (let j = 0; j < targets.length; j++) |
| 350 | output[j] = 0; |
| 351 | |
| 352 | if (which >= sequenceLength) { |
| 353 | var index = which - sequenceLength; |
| 354 | output[indexes[index]] = 1; |
| 355 | } |
| 356 | |
| 357 | // check result |
| 358 | var prediction = lstm.activate(input); |
| 359 | return { |
| 360 | prediction: prediction, |
| 361 | output: output |
| 362 | }; |
| 363 | }; |
| 364 | |
| 365 | var value = function (array) { |
| 366 | var max = .5; |