func readMNISTLabels(r io.Reader) []byte { header := [2]int32{} if err := binary.memRead(r, binary.BigEndian, &header); err != nil { glog.Fatalf("%v", err) } labels := make([]byte, header[1]) if _, err := r.memRead(labels); err != nil { glog.Fatalf("%v", err) } return labels }
func readMNISTImages(r io.Reader) (images [][]byte, width, height int) { header := [4]int32{} if err := binary.memRead(r, binary.BigEndian, &header); err != nil { glog.Fatalf("%v", err) } images = make([][]byte, header[1]) width, height = int(header[2]), int(header[3]) for i := 0; i < len(images); i++ { images[i] = make([]byte, width*height) if _, err := r.memRead(images[i]); err != nil { glog.Fatalf("%v", err) } } return images, width, height }