Test set output

At the end of our training, we should pit our model against the test set.

First, we should import our test data as follows:

if inputs, targets, err = cifar.Load("test", loc); err != nil {
log.Fatal(err)
}

Then, we need recalculate our batches as the test set is sized differently from the train set:

batches = inputs.Shape()[0] / bs
bar = pb.New(batches)
bar.SetRefreshRate(time.Second)
bar.SetMaxWidth(80)

We then need to just add a quick way to track our results and output our results for later inspection by inserting the following code into the accuracy metric calculation code described earlier in the chapter:

// slices to store our output
var testActual, testPred []int

// store our output into the slices within the loop
testActual = append(testActual, rowLabel)
testPred = append(testPred, rowGuess)

And finally, at the end of our run through the entire test set - write the data out to text files:

printIntSlice("testActual.txt", testActual)
printIntSlice("testPred.txt", testPred)

Let's now assess the results.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset