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) }) }
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 }