|
@@ -53,6 +53,10 @@ func NewMNISTReader(dataFilename string, resultsFilename string, validatorFilena
|
|
|
|
|
|
r.dataCount, r.imageSize = openFileSet(dataFilename, resultsFilename)
|
|
|
r.validatorCount, _ = openFileSet(validatorFilename, validatorResultsFilename)
|
|
|
+ r.dataFilename = dataFilename
|
|
|
+ r.resultsFilename = resultsFilename
|
|
|
+ r.validatorFilename = validatorFilename
|
|
|
+ r.validatorResultsFilename = validatorResultsFilename
|
|
|
if r.dataCount <= 0 || r.imageSize <= 0 || r.validatorCount <= 0 {
|
|
|
return nil
|
|
|
}
|
|
@@ -86,12 +90,14 @@ func (r *mnistReader) ValidatorCount() int {
|
|
|
func (r *mnistReader) readData(data string, result string, i int) (buffered, resultsBuffered *mat.Dense) {
|
|
|
file, err := os.Open(data)
|
|
|
if err != nil {
|
|
|
+ log.Fatalf("Could not open data file %v\n", data)
|
|
|
return nil, nil
|
|
|
}
|
|
|
defer file.Close()
|
|
|
|
|
|
resultsFile, err := os.Open(result)
|
|
|
if err != nil {
|
|
|
+ log.Fatalf("Could not open result file %v\n", result)
|
|
|
return nil, nil
|
|
|
}
|
|
|
defer resultsFile.Close()
|
|
@@ -103,9 +109,11 @@ func (r *mnistReader) readData(data string, result string, i int) (buffered, res
|
|
|
_, err = file.Read(buffer)
|
|
|
|
|
|
if err == io.EOF {
|
|
|
+ log.Fatal("EOF reached but shouldn't\n")
|
|
|
return nil, nil
|
|
|
} else if err != nil {
|
|
|
log.Fatal("File read error\n")
|
|
|
+ return nil, nil
|
|
|
}
|
|
|
|
|
|
values := make([]float64, r.imageSize)
|