Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions mnist.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ func (img RawImage) At(x, y int) color.Color {
return color.Gray{img[y*Width+x]}
}

func (img RawImage) AtGray(x, y int) color.Gray {
return color.Gray{img[y*Width+x]}
}


// ReadImageFile opens the named image file (training or test), parses it and
// returns all images in order.
func ReadImageFile(name string) (rows, cols int, imgs []RawImage, err error) {
Expand Down
3 changes: 2 additions & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type Sweeper struct {
// Next returns the next image and its label in the data set.
// If the end is reached, present is set to false.
func (sw *Sweeper) Next() (image RawImage, label Label, present bool) {
sw.i++
if sw.i >= len(sw.set.Images) {
return nil, 0, false
}
Expand All @@ -65,7 +66,7 @@ func (sw *Sweeper) Next() (image RawImage, label Label, present bool) {

// Sweep creates a new sweep iterator over the data set
func (s *Set) Sweep() *Sweeper {
return &Sweeper{set: s}
return &Sweeper{set: s, i: -1}
}

// Load reads both the training and the testing MNIST data sets, given
Expand Down