예제 #1
0
파일: main.go 프로젝트: danieldk/dparnn
func normalizeData(n *input.Normalizer, inFilename string, outFilename string) error {
	outF, err := os.Create(outFilename)
	if err != nil {
		return err
	}
	defer outF.Close()
	trainDataWriter := input.NewTrainDataWriter(outF)

	return processData(inFilename, func(y int, x input.InputVector) error {
		n.Normalize(x)
		return trainDataWriter.Write(y, x)
	})
}
예제 #2
0
파일: io.go 프로젝트: danieldk/dparnn
func ReadNormalizerOrExit(filename string) *input.Normalizer {
	f, err := os.Open(filename)
	ExitIfError("Cannot read normalizer parameter file: ", err)
	defer f.Close()

	data, err := ioutil.ReadAll(f)
	ExitIfError("Cannot read normalizer parameter file: ", err)

	normalizer := new(input.Normalizer)
	err = normalizer.GobDecode(data)
	ExitIfError("Cannot parse normalizer parameters: ", err)

	return normalizer
}