Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let yActual = []
- let yResults = []
- // Looping over each batch in the array of all of the test batches
- for (let i = 0; i < testDataXs.length - 1; i++) {
- // Build the input tensor
- const xs = tf.tensor2d(testDataXs[i])
- // Each prediction makes a series of tensors that build up over time and take up lots of memory.
- // tf.tidy cleans up all the extra tensors after each run to keep the predictions coming quickly!
- tf.tidy(() => {
- // This is where you use the model to predict the outputs on the previously unseen data.
- const preds = model.predict(xs)
- // Keeps the predictions in order due to asynchronisity
- const y_vals = preds.dataSync()
- // Build actual//expected output array
- testDataYs[i].forEach(elem => {
- yActual.push(elem[0])
- })
- // Build predicted results array
- y_vals.forEach(elem => {
- yResults.push(elem)
- })
- })
- }
- // Build a final results array to graph using whichever tool you prefer!
- const fullResults = yActual.map((item, j) => {
- return [item, yResults[j]]
- })
Add Comment
Please, Sign In to add comment