Getting the data

The data is the same data as in the previous chapter: the MNIST dataset. It can be found in the repository for this chapter, and we'll be using a function we wrote in the previous chapter to acquire the data:

// Image holds the pixel intensities of an image.// 255 is foreground (black), 0 is background (white).type RawImage []byte// Label is a digit label in 0 to 9type Label uint8const numLabels = 10const pixelRange = 255const (  imageMagic = 0x00000803  labelMagic = 0x00000801  Width = 28  Height = 28)func readLabelFile(r io.Reader, e error) (labels []Label, err error) {  if e != nil {    return nil, e  }  var magic, n int32  if err = binary.Read(r, binary.BigEndian, &magic); err != nil {    return nil, err  } if magic != labelMagic { ...

Get Go Machine Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.