Guest User

Untitled

a guest
Jun 25th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. let yActual = []
  2. let yResults = []
  3. // Looping over each batch in the array of all of the test batches
  4. for (let i = 0; i < testDataXs.length - 1; i++) {
  5. // Build the input tensor
  6. const xs = tf.tensor2d(testDataXs[i])
  7.  
  8. // Each prediction makes a series of tensors that build up over time and take up lots of memory.
  9. // tf.tidy cleans up all the extra tensors after each run to keep the predictions coming quickly!
  10. tf.tidy(() => {
  11. // This is where you use the model to predict the outputs on the previously unseen data.
  12. const preds = model.predict(xs)
  13. // Keeps the predictions in order due to asynchronisity
  14. const y_vals = preds.dataSync()
  15. // Build actual//expected output array
  16. testDataYs[i].forEach(elem => {
  17. yActual.push(elem[0])
  18. })
  19. // Build predicted results array
  20. y_vals.forEach(elem => {
  21. yResults.push(elem)
  22. })
  23. })
  24. }
  25. // Build a final results array to graph using whichever tool you prefer!
  26. const fullResults = yActual.map((item, j) => {
  27. return [item, yResults[j]]
  28. })
Add Comment
Please, Sign In to add comment